Transformation Rows to columns

Post questions here relative to DataStage Server Edition for such areas as Server job design, DS Basic, Routines, Job Sequences, etc.

Moderators: chulett, rschirm, roy

Post Reply
pramod_au
Participant
Posts: 30
Joined: Thu Feb 06, 2003 8:30 am
Location: London,UK

Transformation Rows to columns

Post by pramod_au »

Hi

I have the following requirement

Input Data:

a|1
a|2
b|2
b|3

Output Data
a|1,2
b|2,3
Thanks
Pramod
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

This is what's known as a "vertical pivot". Search the forum. It's been discussed more than once. There are several techniques, depending on various factors.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
djm
Participant
Posts: 68
Joined: Wed Mar 02, 2005 3:42 am
Location: N.Z.

Post by djm »

And if you can't find it in the forum, one possible solution is the UNIX "paste" command. Try "man paste" for an explanation.
rameshDHL
Premium Member
Premium Member
Posts: 21
Joined: Mon Nov 15, 2004 3:57 am

Vertical Pivot

Post by rameshDHL »

Hi,

Please design your job as follows,

sourcefile - (columnA,coulmnB)--->SortStage(sortby columnA) --Transformer-HashFile(ColumnA as Key)

In Transformer, define 5 stage variables,
sorted.test1 = NewVal
NewVal<>PrevVal = NotEqual
NewVal = PrevVal
sorted.test2 = Column2Val
If Not(NotEqual) then Column2:',':Column2Val else Column2Val = Column2

In the column derivation assign the stage variables to output columns,

sorted.test1 = Column1
Column2 = Coulmn2

Make Column1 as Key in hash file and run the job.

In case if you find any new logic do let us know.....

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

Post by ray.wurlod »

That is a very limited solution, Ramesh. I suspect the OP showed us sample data, not the entire set.

In your design you already have the required result in the stage variables - why do you add a hashed file stage ?
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Post Reply