How to generate the following using data in datastage

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
jpradeep.net
Participant
Posts: 21
Joined: Mon Jul 12, 2010 2:05 am
Location: India

How to generate the following using data in datastage

Post by jpradeep.net »

I have to generate a file with two columns (ID and COMB). ID must contain a sequence number so Integer data type.(I took care of that). COMB column must have the data like this. ( it can be numeric or string)
111111111111111
111111111111110
111111111111100

and so on. The size is 15 and it must have binary only (either 1 or 0).
so, we can get (2 power 15)=32768 combinations.
that means

1. 111111111111111
2. 111111111111110
3. 111111111111100
|
|
|
32768. 000000000000000
qt_ky
Premium Member
Premium Member
Posts: 2895
Joined: Wed Aug 03, 2011 6:16 am
Location: USA

Post by qt_ky »

Is this a training exercise?

You know all ones = 32768 and all zeros = 0. Following your logic, you should start with ID = 0, right? Do you care about the order?
Choose a job you love, and you will never have to work a day in your life. - Confucius
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Much, much, much easier done in a server job. Is this an interview question?

In a server job, generate the integers using a Transformer stage and, in that stage, generate the binary equivalents using Oconv(integer, "MB0C") then left-pad with zeroes as required.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
qt_ky
Premium Member
Premium Member
Posts: 2895
Joined: Wed Aug 03, 2011 6:16 am
Location: USA

Post by qt_ky »

Correction: all ones = 32767
Choose a job you love, and you will never have to work a day in your life. - Confucius
qt_ky
Premium Member
Premium Member
Posts: 2895
Joined: Wed Aug 03, 2011 6:16 am
Location: USA

Post by qt_ky »

In a parallel job, you can do this with a Row Generator to create the ID as a number 1 through 32768, then a Transformer stage derivation for the COMB column:

Code: Select all

BitExpand(32768 - lnk.ID)[15]
The BitExpand function returns a string of the binary representation a given integer. The [15] takes the right-most 15 characters. The minus part gives you the "reversed order" you mentioned, where ID 1 gives COMB of all ones (15 ones represents integer 32767) and ID 32768 gives COMB of all zeros, representing integer value zero.

Output to a Sequential File and apply whatever sorting you want, i.e. based on the ID, in the stage properties.
Choose a job you love, and you will never have to work a day in your life. - Confucius
jpradeep.net
Participant
Posts: 21
Joined: Mon Jul 12, 2010 2:05 am
Location: India

Hi Eric Dodson, Thank you for the reply

Post by jpradeep.net »

Thanks a lot for the reply, but i just want to have the combination of the 1 and zero for the length of 15 and every combination must be unique.for example 100000000000000
000000000000001
000000000000011
000000000001111
and so on. We have to use 1 and 0 only and the length is 15 so 2 power 15=32768 combinations.there is no particular order also. I have to get each combination in a separate row.this is not a training exercise.
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

That's what Eric's solution will give you.
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