Hello,
I have data structured as follows:
Record # | ID | Col1 | Col2 | Col3 |
1 | 1000 | a | b | c |
2 | 2000 | d | e | f |
3 | 2000 | g | h | i |
4 | 3000 | j | k | l |
5 | 4000 | m | n | o |
What I want to do is randomly select an ID with equal probability then output a table with every row with that ID. So I used Unique on column ID to pull out records with unique IDs (records 1,2,4,5. Then Random % Sample (with Random N=1 Records) to pull out one of these rows. If I randomly selected ID 1000, 3000, or 4000 my job is done. But how do I ensure I get back Records #2 and #3 if I randomly selected ID 2000? Is there a way to finish my approach or is there a simpler way?
Thanks
Solved! Go to Solution.
Hey @skwan,
Based on what I am gathering from the info provided, you could do the random sample to get that value and then join it back onto the original dataset to get all occurrences of that ID.
This should work even if the ID only shows up once.
Let me know if this works.
Okay that makes sense. The join tool normally adds additional columns for the join but I would be unchecking the boxes in the tool configuration for all the right table elements?
Thanks I think that should work.
To answer your question would depend on what is in each one, but yes you would remove any unwanted output fields.
Excellent! If it doesn't let me know and I can think through what else could be done.