11-20-2014 11:22 AM
I have a task that I need to accomplish. I have FirstName that I need to either switch around or assign random names to it.
FirstName (randomized) (Note: These are just random names)
The goal is to assign consistent random names or switch the characters around using a logic. This logic must however generate consistent translation. For instance, in the above dataset, all occurrences of John and Charles must be translated to Bill (or any name generated by your code) and Salt (or any name generated by your code) respectively as with the random test data
Thanks and I look forward to hearing from you all.
11-20-2014 11:49 AM
Does your "randomization" require that no name have a chance of being assigned it's original value?
If not this is one approach that scrambles the names without introducing any new words. The smaller the number of unique names the larger the chance that one or more of the names will be assigned it's original value.
input Name $;
create table uniquenames as
select distinct Name
rand = ranuni(123);
proc sort data=temp out=temp2; by rand;run;
temp2 (rename=(name=NewName) drop=order)
fmtname = "Rename";
label = NewName;
proc format library=work cntlin=cntldata;run;
proc print data=start;
format name $rename.;
Note: you could use the format $rename to either actually change the value in a data step:
name = put(name,$rename.);
or create a new variable
RandName = put(name,$rename.);
or neither and just associate the format when using the variable.
11-20-2014 12:04 PM
The names can be assigned it's original value so long the percentage of such names are insignificant. Also, the names don't have to be meaningful names. Thanks