String aggregation

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
urshit_1983
Participant
Posts: 73
Joined: Wed Jun 28, 2006 3:27 pm
Location: NJ

String aggregation

Post by urshit_1983 »

I am finding it hard to find out whether the following thing can be done in DS ??


Input is like :-

Custname--------------Custid

Mel --------------- 001
Dino----------------------002
Mel------------------------007
Dino-----------------------009
Jack------------------------100
Jack------------------------200



Outout I want is like:-

Custname------------------Custid

Mel--------------------------001,007
Dino-------------------------002,009
Jack-------------------------100,200


(----) is just to separate two columns.


Thanks
"Nobody is expert in Everything,
But Everybody is expert in Something."
Krazykoolrohit
Charter Member
Charter Member
Posts: 560
Joined: Wed Jul 13, 2005 5:36 am
Location: Ohio

Post by Krazykoolrohit »

Sort the data stream on Custname.

in the transformer add three stage variables Var1, Var2 and Var3.

Code: Select all

Derivation of Var1:

If Custname=Var3 then 0 else 1

Derivation of Var2:

If Custname=Var3 then Custid:',':Var2 Else ' '

Derivation of Var3:

If Custname=Var3 then Var3 Else Custname
I hope you understood the logic.

Use Var3 in the output link. also add a constraint to the link (pass rows only where Customername!=Var3 as:

Var1=1
DSguru2B
Charter Member
Charter Member
Posts: 6854
Joined: Wed Feb 09, 2005 3:44 pm
Location: Houston, TX

Post by DSguru2B »

I think even the row merger can take care of your problem. Look into the row merger stage.
Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.
Krazykoolrohit
Charter Member
Charter Member
Posts: 560
Joined: Wed Jul 13, 2005 5:36 am
Location: Ohio

Post by Krazykoolrohit »

But how will we concatenate different rows in row merger concatenating one column but leaving the other intact?
jdmiceli
Premium Member
Premium Member
Posts: 309
Joined: Wed Feb 22, 2006 10:03 am
Location: Urbandale, IA

What about the Pivot Stage for this?

Post by jdmiceli »

Hi all,

Wouldn't the pivot stage work in this case as well?

Bestest!
Bestest!

John Miceli
System Specialist, MCP, MCDBA
Berkley Technology Services


"Good Morning. This is God. I will be handling all your problems today. I will not need your help. So have a great day!"
Krazykoolrohit
Charter Member
Charter Member
Posts: 560
Joined: Wed Jul 13, 2005 5:36 am
Location: Ohio

Post by Krazykoolrohit »

Just post in all the possible solutions so that our dear friend gets all options before him.
DSguru2B
Charter Member
Charter Member
Posts: 6854
Joined: Wed Feb 09, 2005 3:44 pm
Location: Houston, TX

Post by DSguru2B »

I am not exactly sure. I do not have access to datastage at the moment. But it looked as if it was possible by row merger. I have never used that stage personally, just played around with it once.
Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.
urshit_1983
Participant
Posts: 73
Joined: Wed Jun 28, 2006 3:27 pm
Location: NJ

Post by urshit_1983 »

the variable method by rohit is not working. I have not tried the other two methods.

Will get back to you guys again...
"Nobody is expert in Everything,
But Everybody is expert in Something."
urshit_1983
Participant
Posts: 73
Joined: Wed Jun 28, 2006 3:27 pm
Location: NJ

Post by urshit_1983 »

DSGuru I tried Row merger but getting confused. I am getting strange results. I have also never used this stage before so a bit ignorant on this. Your help would be appreciated.
"Nobody is expert in Everything,
But Everybody is expert in Something."
us1aslam1us
Charter Member
Charter Member
Posts: 822
Joined: Sat Sep 17, 2005 5:25 pm
Location: USA

Post by us1aslam1us »

You can try this :

Code: Select all


VarResult=> If Custname=Var1 then VarCustid:',':Custid else Custid 
Var2=> Var1 
Var1=> A 

In the output columns define

Custname=>Custname 
Custid=>VarResult

After transformer use remove duplicate stage for removing the duplicates and retain the last rows for each set.

May be guru can help you in tweaking this :?: .

Sam
DSguru2B
Charter Member
Charter Member
Posts: 6854
Joined: Wed Feb 09, 2005 3:44 pm
Location: Houston, TX

Post by DSguru2B »

I did something similar a while back. Check out thispost.
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 »

It's a vertical pivot. Search the forum for this term. At least three techniques have been published here.
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