Merging Column Data

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
mgray412
Participant
Posts: 12
Joined: Tue Jan 18, 2011 10:18 am

Merging Column Data

Post by mgray412 »

I need to combine data from several columns into 1 column only showing any duplicates only once in the output column. For example:

Col 1 = A
Col 2 = B
Col 3 = A
Col 4 = C
Col 5 = B

The output column should be: A B C

How can I do this in DataStage?

Thanks in advance for all your help
kwwilliams
Participant
Posts: 437
Joined: Fri Oct 21, 2005 10:00 pm

Re: Merging Column Data

Post by kwwilliams »

If the number of columns is fixed then you could do it in stage variables.

svCol2 = if Count(Column1, Column2) > 0 Then '' Else Column2
svCol3 = if Count(Column1:svCol2,Column3) > 0 Then '' Else Column3
svCol4 = if Count(Column1:svCol2:svCol3,Column4) > 0 Then '' Else Column4
svCol5 = if Count(Column1:svCol2:svCol3:svCol4,Column5) >0 Then '' Else Column5

Answer = Column1:svCol2:svCol3:svCol4:svCol5

Count is the number of occurences of a substring within a string, if the count is greater than 0 it means the value already existed and you wouldn't want to add it to your final answer, so you set it to blank.
mgray412
Participant
Posts: 12
Joined: Tue Jan 18, 2011 10:18 am

Re: Merging Column Data

Post by mgray412 »

Keith,

That solved my problem. Thanks for your help!!
Post Reply