a complex requirment.

Post questions here relative to DataStage Enterprise/PX Edition for such areas as Parallel job design, Parallel datasets, BuildOps, Wrappers, etc.

Moderators: chulett, rschirm, roy

Post Reply
arnie_nits
Participant
Posts: 101
Joined: Mon Aug 13, 2007 2:32 am

a complex requirment.

Post by arnie_nits »

Hi,

I have a complex requirment.

I have records like:

id Fe Zn Ag
1 10 20 30
2 5 6 8


Now I want the records like:

id test value
1 Fe 10
1 Zn 20
1 Ag 30
2 Fe 5
2 Zn 6
2 Ag 8


Can we do that in Datastage.....Please help...

Regards,
Arnie.
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

That requirement is for a "horizontal pivot" and is precisely what the Pivot stage provides.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

Use stage variables to store the distinct column headers from the first row, i.e. SvarCol2 is "IF NOT(In.Col2) THEN In.Col2 ELSE SvarCol2". Then derive your output columns from the data and your stage variables. Manually add a line terminator after the column value and write to a sequential file or use the pivot stage to split the rows.
arnie_nits
Participant
Posts: 101
Joined: Mon Aug 13, 2007 2:32 am

Post by arnie_nits »

Well I am partly successful....

I am able to get..

Id Value
1 10
1 20
1 30
2 5
2 6
2 8

But was not able to get Fe,Zn,Ag...etc...as column values....


Regards,
Arnie.
Sainath.Srinivasan
Participant
Posts: 3337
Joined: Mon Jan 17, 2005 4:49 am
Location: United Kingdom

Post by Sainath.Srinivasan »

If there are less columns (as 3 in your example), you can hardcode them in 3 separate links and funnel them together to get your output.
arnie_nits
Participant
Posts: 101
Joined: Mon Aug 13, 2007 2:32 am

Post by arnie_nits »

there are many columns......20 to be exact.....

Regards,
Arnab.
Sainath.Srinivasan
Participant
Posts: 3337
Joined: Mon Jan 17, 2005 4:49 am
Location: United Kingdom

Post by Sainath.Srinivasan »

20 is not many.
arnie_nits
Participant
Posts: 101
Joined: Mon Aug 13, 2007 2:32 am

Post by arnie_nits »

Could u please explain the funnel logic....I guess Join will be more useful...

here is my requirment

I have records like:

id Fe Zn Ag
1 10 20 30
2 5 6 8


Now I want the records like:

id test value
1 Fe 10
1 Zn 20
1 Ag 30
2 Fe 5
2 Zn 6
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

My stage variable response also applies when you use the pivotr stage.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Or just include a hard-coded set of fields on the link before the pivot that you've set to the column names and pivot that along with the others.
-craig

"You can never have too many knives" -- Logan Nine Fingers
Post Reply