Address Shuffle
Moderators: chulett, rschirm, roy
-
- Participant
- Posts: 248
- Joined: Fri Jul 30, 2010 9:04 am
Address Shuffle
I have a source file with 1M records which has addresses in it.
Please provide me an idea to shuffle the addresses with in the file and also the addresses should be from the same state.
I sorted the state_cd field and generated a key column to identify the state change.
Can any one help me out the next step or any other idea?
Please provide me an idea to shuffle the addresses with in the file and also the addresses should be from the same state.
I sorted the state_cd field and generated a key column to identify the state change.
Can any one help me out the next step or any other idea?
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
Shuffle = Randomize, in a sense. As in re-arrange whom has which address within a given state.
Last edited by chulett on Thu Dec 06, 2012 2:34 pm, edited 1 time in total.
-craig
"You can never have too many knives" -- Logan Nine Fingers
"You can never have too many knives" -- Logan Nine Fingers
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
Re: Address Shuffle
I will try to explain using one example
suppose your records is like below one
"Name Address State"
Now you want to shuffle Name and Address with the state
Ans: Split the record into two streams
1: Name + State
2: Address + State
Now add new column "Order" for both streams and use use Random function to get the value (I haven't used the random function in DataStage. It should not give same sequence.. otherwise we have to find another way to so that it give different sequece each time). Then partition only using "State" and sort using "State, Order". This should give you different order in both the streams. Now add another column "Key" to both streams and assign values 0, 1, 2 etc for each State (or simply assigning @INROWNUM also should work).
Now you can join Both the streams on "State and Key" columns and output will be shuffled.
suppose your records is like below one
"Name Address State"
Now you want to shuffle Name and Address with the state
Ans: Split the record into two streams
1: Name + State
2: Address + State
Now add new column "Order" for both streams and use use Random function to get the value (I haven't used the random function in DataStage. It should not give same sequence.. otherwise we have to find another way to so that it give different sequece each time). Then partition only using "State" and sort using "State, Order". This should give you different order in both the streams. Now add another column "Key" to both streams and assign values 0, 1, 2 etc for each State (or simply assigning @INROWNUM also should work).
Now you can join Both the streams on "State and Key" columns and output will be shuffled.
-
- Participant
- Posts: 248
- Joined: Fri Jul 30, 2010 9:04 am
-
- Participant
- Posts: 248
- Joined: Fri Jul 30, 2010 9:04 am
Just to be clear my requirement is
Before: 1)John, 123 rew dr,chicago, IL
2)Anthony, 456 qwe dr, springfield, IL
3)Ronny, 789 hjg dr, queens, NY
4)Joseph, 345 kli dr, nyc, NY
After: 1)John, 456 qwe dr, springfield,IL
2)Anthony, 123 rew dr,chicago,IL
3)Ronny, 345 kli dr,nyc, NY
4)Joseph, 789 hjg dr, queens, NY
Thank you!
Before: 1)John, 123 rew dr,chicago, IL
2)Anthony, 456 qwe dr, springfield, IL
3)Ronny, 789 hjg dr, queens, NY
4)Joseph, 345 kli dr, nyc, NY
After: 1)John, 456 qwe dr, springfield,IL
2)Anthony, 123 rew dr,chicago,IL
3)Ronny, 345 kli dr,nyc, NY
4)Joseph, 789 hjg dr, queens, NY
Thank you!
Regards,
Kenny
Kenny
-
- Participant
- Posts: 248
- Joined: Fri Jul 30, 2010 9:04 am