Pivot dynamic columns to rows

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
pratapsriram
Premium Member
Premium Member
Posts: 41
Joined: Tue Jan 24, 2006 3:43 pm
Location: United States
Contact:

Pivot dynamic columns to rows

Post by pratapsriram »

I have a unique problem.
Securities data looks like this:
Credit Family BB Internal PP or CUSIP
1166 AVENUE OF THE AMERICAS COMMERICAL MTG TRUST 682439AC8
1166 AVENUE OF THE AMERICAS COMMERICAL MTG TRUST 682439AE4
1166 AVENUE OF THE AMERICAS COMMERICAL MTG TRUST 682439AJ3
1166 AVENUE OF THE AMERICAS COMMERICAL MTG TRUST 682439AN4
1166 AVENUE OF THE AMERICAS COMMERICAL MTG TRUST 682439AU8
125 HOME LOAN OWNER TRUST 68240MAE8
1345 AVE OF THE AMERICAS & PARK AVE PLAZA TRUST 68275CAC2
1345 AVE OF THE AMERICAS & PARK AVE PLAZA TRUST 68275CAD0
1345 AVE OF THE AMERICAS & PARK AVE PLAZA TRUST 68275CAE8
1345 AVE OF THE AMERICAS & PARK AVE PLAZA TRUST 68275CAF5
1345 AVE OF THE AMERICAS & PARK AVE PLAZA TRUST 68275CAG3
1345 AVE OF THE AMERICAS & PARK AVE PLAZA TRUST 68275CAH1

I have changed it to this format:

Credit Family,BB Internal PP or CUSIP,BB Internal PP or CUSIP,BB Internal PP or CUSIP,BB Internal PP or CUSIP,BB Internal PP or CUSIP,BB Internal PP or CUSIP
1166 AVENUE OF THE AMERICAS COMMERICAL MTG TRUST,682439AC8,682439AE4,682439AJ3,682439AN4,682439AU8,
125 HOME LOAN OWNER TRUST,68240MAE8,,,,,
1345 AVE OF THE AMERICAS & PARK AVE PLAZA TRUST,68275CAC2,68275CAD0,68275CAE8,68275CAF5,68275CAG3,68275CAH1

The final output format, after doing a pivot, looks like this:
Value_field
1166 AVENUE OF THE AMERICAS COMMERICAL MTG TRUST
682439AC8
682439AE4
682439AJ3
682439AN4
682439AU8


125 HOME LOAN OWNER TRUST
68240MAE8






1345 AVE OF THE AMERICAS & PARK AVE PLAZA TRUST
68275CAC2
68275CAD0
68275CAE8
68275CAF5
68275CAG3
68275CAH1

Lastly I will delete the empty lines so there is no blank values. This is the format required for loading into another tool.
But this means the number of columns is varying. I want to know what is the maximum number of columns we can define so that once we define it and making use of the incomplete column we will be ok. But I already know that for some Credit Family like US Treasury, the number of values can range into 500 rows. So can we give 1000 columns in the sequential read file to achieve this?
Or does anyone have another approach for solving this?

Thanks,
Sreeram
Knowledge is Power
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

This is not actually a pivot.

Do it with stage variables and you won't have any issues with the number of rows.

Output the company name only when it changes.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Kryt0n
Participant
Posts: 584
Joined: Wed Jun 22, 2005 7:28 pm

Post by Kryt0n »

You appear to be trying to do two pivots just to remove data?

Why doesn't the first row for each security output the name followed by reference number and all subsequent rows just output the reference number?
You will need suitable partitioning and sorting but sounds simpler
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

It's a server job, so there's no partitioning.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Kryt0n
Participant
Posts: 584
Joined: Wed Jun 22, 2005 7:28 pm

Post by Kryt0n »

Maybe one day I'll look at the forum first...
pratapsriram
Premium Member
Premium Member
Posts: 41
Joined: Tue Jan 24, 2006 3:43 pm
Location: United States
Contact:

Post by pratapsriram »

This is what I understood - Use stage variables to construct the line "Credit Family Name" with the "\n" and append with the Security identifier when the name changes so that a new line with the Credit family name appears...
Knowledge is Power
Post Reply