Page 1 of 1

Creating the sequence nbrs in a file.

Posted: Tue Apr 22, 2008 2:48 pm
by vidya_6_2000
I have a special requirement. My file has the following columns.
A,B,C. with A being the main column. and file sorted by A.
I need to create an output file which has the following columns.
S,A,B,C. A, B and C are derived from the above I/P file columns and S is derived based on the following rule.
S = 01 for every unique value of A.
But if there are 2 records with the same value of A then S in incremented to 02,03 and so on, depending on how many records have the same value of A.
Here is an example of I/P file.
A B C
1 1b 1c
2 2b 2c
2 2d 2e
3 3b 3c
Here is an example of O/P file needed.
S A B C
01 1 1b 1c
01 2 2b 2c
02 2 2d 2e
01 3 3b 3c

Please do let me know how we could do this in DATASTAGE.

All help is greatly appreciated.

With Warm Regards,
Vidya Iyer

Posted: Tue Apr 22, 2008 4:10 pm
by ray.wurlod
Sort with a Sort stage and have it generate a key change column. In a downstream Transformer stage reset the counter to 1 if the key change column is 1, otherwise increment the counter.

Posted: Tue Apr 22, 2008 11:14 pm
by bikan
I guess we also need to take care of partition...you may have to put hash partion of column A and then put same partion in transformer..or you can run transformer in sequential mode