Convert Pivot to Flat file

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
vskr72
Premium Member
Premium Member
Posts: 128
Joined: Wed Apr 28, 2004 9:36 pm

Convert Pivot to Flat file

Post by vskr72 »

I have a file in this format.

.........P1 P2 P3............................
A001 v11 v21 v31.......................
A002 v12 v22 v32.......................
A003 v13 v23 v33.......................
A004 v14 v24 v34.......................
.................................................
.................................................
.................................................
A00n

This has to be flattened in this format

A001 P1 v11
A001 P2 v21
A001 P3 v31
A001 P4 v41
...
...
...

Please let me know if there is a good way to do it in Datastage (Server Ed.) or should I use AWK to do it?

Kumar
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 called a horizontal pivot and is exactly what the Pivot stage is intended to do.
Look in your manuals for Pivot.pdf which explains how to use it, with examples.
Search the forum for an example of pivoting the constants (P1 through P4).
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