03-03-2012 07:16 PM
Hi I have a data set containing names, addresses, phone numbers etc and I need to randomise some of the data so I can share it.
Ideally I want to change all the first names. Is there anyway I can have a list of say 5 names I choose and then randomly apply them to all the names in my data set e.g.
Data Set Name Original:
5 names used to randomise:
Data Set Name after randomisation:
Any help would be greatly appreciated.
03-03-2012 07:35 PM
Or if there are too many replacement names to pack it into a string:
input name $;
input RepName $;
data want(drop=_: repID);
set have RepNames(obs=0 keep=repID RepName);
if _n_=1 then
declare hash h1(dataset:'RepNames');
proc print data=want;
03-03-2012 08:26 PM
Building on Tom's suggestion, if the set of random names is in a dataset called otherNames then you could use :
proc sql noprint;
select name into :randNames SEPARATED BY ' ' from otherNames;
select count(name) into :nameCount from otherNames;
data want ;
name = scan("&randNames.",ceil(&nameCount.*ranuni(0)));