08-26-2016 10:56 AM
I am trying to assign random numbers to a given set of IDs. The reason for assinging random numbers to the IDs is to de-identify the information from the IDs. There should not be any relationship between the IDs and the Random numbers generated from them. For example:
if I have a set of IDs as:
The random numbers in the above tables are just the examples. These numbers can be any given number until and unless there is no relationship between the IDs and Random numbers. The only intention for decoding the IDs is to secure the information. Again, these random numbers cannot be used to lookback the IDs.
09-01-2016 10:16 AM - edited 09-01-2016 10:18 AM
Thanks Ksharp. This code works. If I wanted to assign random numbers in particular range how should I modify the code. For example for a given set of 2000 IDs I want to assign random numbers in the range 100000- 102000. How should I do this. For example:
My output should look something like:
In the above example, the number of observations in the dataset are 2000. The Random numbers are assigned such that they are in particular range i.e 100000-102000.
Thanks for your help
09-02-2016 12:09 AM
data have; do obs=1 to 2000; output; end; run; data temp; set have; ran=ranuni(0); run; proc rank data=temp out=want; var ran; ranks r; run; data want; set want; random=100001+r; drop r; run;
09-02-2016 12:12 AM
Last code is not right. Try this one: data have; do obs=1 to 2000; output; end; run; data temp; set have; ran=ranuni(0); run; proc rank data=temp out=want; var ran; ranks r; run; data want; set want; random=100000+r; drop r; run; proc sql; select count(distinct random),max(random),min(random) from want;quit;
Need further help from the community? Please ask a new question.