joining the common rows

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
us1aslam1us
Charter Member
Charter Member
Posts: 822
Joined: Sat Sep 17, 2005 5:25 pm
Location: USA

joining the common rows

Post by us1aslam1us »

Hi all,

I am having an input:

name,add,loc,pos
A,l,s,BA
A,l,s,CA
A,l,s,DA

i need to transform it to

name,add,loc,pos
A,l,s,BA/CA/DA

I tried to use stage variables but any help is appreciated.

Thanks
Sam
vmcburney
Participant
Posts: 3593
Joined: Thu Jan 23, 2003 5:25 pm
Location: Australia, Melbourne
Contact:

Post by vmcburney »

Stage variables will do the trick as long as the data is sorted and partitioned by the key columns A,I,s. Stage variables can hold values from previous rows as long as you fire them in the right order.

Something like this:
NewKey=input.name:|:input.add:|:input.loc
Separator=IF NewPos<>"" THEN "/" ELSE ""
NewPos=IF NewKey=OldKey THEN Pos:Separator:input.pos ELSE ""
OldKey=NewKey
us1aslam1us
Charter Member
Charter Member
Posts: 822
Joined: Sat Sep 17, 2005 5:25 pm
Location: USA

Post by us1aslam1us »

Thanks for the response vincent but it had been resolved way back with the same solution you provided.
I haven't failed, I've found 10,000 ways that don't work.
Thomas Alva Edison(1847-1931)
Post Reply