How do to add a line for each value in the Column

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
DS_MJ
Participant
Posts: 157
Joined: Wed Feb 02, 2005 10:00 am

How do to add a line for each value in the Column

Post by DS_MJ »

Hello:

How to add a line for each value in the Column?

Example:
Column value in COL_A is CH, SE, SR, etc,

So for COL_A , there will be 3 rows.
Thanks in advance,
DSguru2B
Charter Member
Charter Member
Posts: 6854
Joined: Wed Feb 09, 2005 3:44 pm
Location: Houston, TX

Post by DSguru2B »

Use the CONVERT() function and convert all commas with char(010) (new line character on unix).
This will be sufficient if there is only one column in your source. If you have multiple columns, then you can use the pivot stage.
Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.
DS_MJ
Participant
Posts: 157
Joined: Wed Feb 02, 2005 10:00 am

Post by DS_MJ »

DSguru2B wrote:Use the CONVERT() function and convert all commas with char(010) (new line character on unix).
This will be sufficient if there is only one column in your source. If you have multiple columns, then you can use the pivot stage.
Thanks DSguru2B for the quick response. I will go ahead and try it.
Thanks in advance,
DS_MJ
Participant
Posts: 157
Joined: Wed Feb 02, 2005 10:00 am

Post by DS_MJ »

Hi DSguru2B

This is the first time I am using a Pivot Stage.

I have multiple columns on the source file. A Horizontal Pivot would create columns within a single row into many rows)


My Source file looks like this:

Code: Select all

COL_A                                  |   COL_B      | COL_C       | and so on
AC, AG, MA, MM, PH, RE, SR, VO         |       1      | ZA0         | ......
MH, BO,NA                              |       2      | ZZZ         |
Under COL_A I have values AC, AG, MA, MM, PH, RE, SR, VO and there should only be one value in this column, so there should be 8 rows here, one for each value and not just one.

SO My Target should populate Like below:

Code: Select all

  COL_A               |     COL_B         | COL_C       | and so on
AC                    |         1         | ZA0         | ......
AG                    |         1         | ZA0         |
MA                    |         1         | ZA0         |
MM                    |         1         | ZA0         | ......
AG                    |         1         | ZA0         |
PH                    |         1         | ZA0          | ......
AG                    |         1         | ZA0         |
RE                    |         1         | ZA0          | ......
AG                    |         1         | ZA0         |
SR                    |         1         | ZA0         | ......
AG                    |         1         | ZA0         |
VO                    |         1         | ZA0         | ......
AG                    |         1         | ZA0         |
MH                    |         2         | ZZZ         |
BO                    |         2         | ZZZ         |
NA                    |         2         | ZZZ         |

 
Can I achieve this with using Pivot stage...?
Thanks in advance,
DSguru2B
Charter Member
Charter Member
Posts: 6854
Joined: Wed Feb 09, 2005 3:44 pm
Location: Houston, TX

Post by DSguru2B »

Sure you can. Read about the pivot stage in its pdf help file. It explains with examples to give you a clear understanding.
Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.
DS_MJ
Participant
Posts: 157
Joined: Wed Feb 02, 2005 10:00 am

Post by DS_MJ »

Hello DSguru2B:

I am using DS 7.5.2.

In the Help ---under Px Job Stages ---> Processing Stages I dont see the Pivot stage I see all the other stages, nor is it underRestructure stage. When I do a find it just gives the stage its Input and output pages and explanation about it. There is no example. Is there somewhere else I can get this..?
Thanks in advance,
DSguru2B
Charter Member
Charter Member
Posts: 6854
Joined: Wed Feb 09, 2005 3:44 pm
Location: Houston, TX

Post by DSguru2B »

GO to the Online documentation. Hit start on your desktop, go to Programs, find Ascential DataStage and go to Online Manuals.
Click on DataStage Documentation, then go to Plugin Stages. Once inside, search for Pivot Stage and read its manual.
You can also search here about pivot stage and real time examples that dsxians faced.
Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

One of the examples in the manual (Pivot.pdf) is almost exactly your scenario.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
DS_MJ
Participant
Posts: 157
Joined: Wed Feb 02, 2005 10:00 am

Post by DS_MJ »

Hi DSguru2B:

Thanks I did find Pivot stage in the Plugins. The example showing in there has a difference. In the example it has different Columns that need pivoting. So it has columns Jan, Feb,Mar that are pivoted.

However, my job in 1 column (COL_A) it has data seperated by a comma and this seperated data from just COL_A needs to be pivoted.

I used the pivot stage and was able to pivot columns. But mine is
value in a column which is seperated by a comma that needs pivoting and am unable to do it.

So I was able to pivot some columns but i was unable to pivot the data in COL_A which is seperated by a comma.
Thanks in advance,
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Simply parse these data into separate columns. Use a Transformer stage with Field() functions or a Column Import 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.
Team_2007
Premium Member
Premium Member
Posts: 11
Joined: Mon Jun 11, 2007 6:10 am

Post by Team_2007 »

Use EREPLACE fucntion to achieve this.
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Yeah? How, precisely?
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