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
Merging Column Data
Moderators: chulett, rschirm, roy
-
- Participant
- Posts: 437
- Joined: Fri Oct 21, 2005 10:00 pm
Re: Merging Column Data
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.
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.
Keith Williams
keith@peacefieldinc.com
keith@peacefieldinc.com
Re: Merging Column Data
Keith,
That solved my problem. Thanks for your help!!
That solved my problem. Thanks for your help!!