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
How to generate the following using data in datastage
Moderators: chulett, rschirm, roy
-
- Participant
- Posts: 21
- Joined: Mon Jul 12, 2010 2:05 am
- Location: India
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
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.
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.
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
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:
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.
Code: Select all
BitExpand(32768 - lnk.ID)[15]
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
-
- Participant
- Posts: 21
- Joined: Mon Jul 12, 2010 2:05 am
- Location: India
Hi Eric Dodson, Thank you for the reply
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.
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.
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact: