Converting rows into columns

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
divine
Premium Member
Premium Member
Posts: 149
Joined: Fri Oct 15, 2004 12:13 am
Location: Toronto,divine_auro@yahoo.co.in
Contact:

Converting rows into columns

Post by divine »

Hi,

I have got a sequential file having 10 records into it. I want to transpose the recordset. How it can be done. For eg I ve got the following records at the input -
1 AA
2 BB
3 CC

The output should be -
1 2 3
AA BB CC

Please let me know how it can be done.
Thanks in advance,
Arindam.
With Regards
Biswajit
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Search for "vertical pivot", for it is that which you are striving to accomplish.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
abhishekachrekar
Participant
Posts: 45
Joined: Wed May 02, 2007 8:30 am
Location: Prague, Czech Republic

Post by abhishekachrekar »

Hi Ray,

Can we use vertical pivot when we dont know the number of rows?

Eg
My file contains

1 AA
2 BB
3 CC
.
.
.
<N> LMT
Where <N> is any integer value.

Actually my requirement is as follows.
My file contains following recs.

A1 1
A2 2
A3 3
A4 4
A5 5

Now I have to generate following recs in addition to the above recs.
B1 A1(value)/A3(value)
B2 A2(value)/A4(value)

now A1(value) is the col2 value corresponding to A1 in the input file.
Since it is difficult to do calculations on data in different rows, I thought of transposing the rows to columns. But since the number of rows are not known I find it difficult to transpose it.

Kindly advise if there is any other way to achieve the result.

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

Post by ray.wurlod »

This is very easy to do in a server job. Are you prepared to go that route?

Write into a hashed file or UniVerse table normalized on a multi-valued field then read it back un-normalized, converting the value marks (@VM) to whatever delimiter you require.
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