need logic

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
dstest
Participant
Posts: 66
Joined: Sun Aug 19, 2007 10:52 pm

need logic

Post by dstest »

I have 6 columns in my file.

ID,CODE1,CODE2,CODE3,CODE4,CODE5
123,300,200,500,600,20
123,400,40,30,300,20

I need the output like below

ID,CODE1,CODE2,CODE3,CODE4,CODE5
123,300,200,500,600,20,400,40,30,300,20

Can any one have any idead about how to do this in datatsage

Thanks
paddu
Premium Member
Premium Member
Posts: 232
Joined: Tue Feb 22, 2005 11:14 am
Location: California

Re: need logic

Post by paddu »

dstest wrote:I need the output like below

ID,CODE1,CODE2,CODE3,CODE4,CODE5
123,300,200,500,600,20,400,40,30,300,20

How many output columns you have ???
kcbland
Participant
Posts: 5208
Joined: Wed Jan 15, 2003 8:56 am
Location: Lutz, FL
Contact:

Post by kcbland »

Seems like sorting and stage variables will do the trick.
Kenneth Bland

Rank: Sempai
Belt: First degree black
Fight name: Captain Hook
Signature knockout: right upper cut followed by left hook
Signature submission: Crucifix combined with leg triangle
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

You have more columns than column headings in your desired output. Please be more precise about the specification of your requirement.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
htrisakti3
Charter Member
Charter Member
Posts: 36
Joined: Thu Jun 10, 2004 11:22 pm

Post by htrisakti3 »

if I can infer by your example, you want to concatenate lines that have same ID.

Here's how i'd do it:
1. read all fields into 1 long varchar --> file1
2. using Field() read out ID, & write to hashedfile HF_id (ID, str1)
3. in another job, src=file1 ; lookup: HF_id ; out=HF_id (key=ID)
in Tfm, if ID match found --> concatenate existing value of HF_id.str1

try out & let us know..
htrisakti3
Charter Member
Charter Member
Posts: 36
Joined: Thu Jun 10, 2004 11:22 pm

Post by htrisakti3 »

htrisakti3 wrote:if I can infer by your example, you want to concatenate lines that have same ID.

Here's how i'd do it:
1. read all fields into 1 long varchar --> file1
2. using Field() read out ID, & write to hashedfile HF_id (ID, str1)
3. in another job, src=file1 ; lookup: HF_id ; out=HF_id (key=ID)
in Tfm, if ID match found --> concatenate existing value of HF_id.str1

try out & let us know..
sorry i meant to say that use Server job to reconstruct the file..
dhanashreepanse
Participant
Posts: 25
Joined: Fri Jan 11, 2008 12:49 am
Location: Pune, India

Post by dhanashreepanse »

You can also try this with a PX job:
1. Sort the input based on the ID column and generate Rank_Num starting from 1 wherever the ID changes.
2. Use a filter stage and have 2 outputs from it. First one filters outs all rows with Rank_Num=1 and second one filters out all rows with Rank_Num<>1.
3. Use a Join stage with a Left outer condition. Left link would be the row with Rank_Num=1. Take the required columns from the other rows on the right link.

Let us know if this works.

Regards,
Dhanashree
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

:roll:
Why are you all wasting your time guessing the requirement? Why not wait until dstest posts the precise requirement, as asked?
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