少呃 发表于 2010-3-11 22:38 
请问要怎么产生以字母开头后随9位数字的5000个随机ID号?
程序应该怎么写?
请高人指教!谢谢!
Here is the one. I do a little trick to manuplate a seed in SAS. The results look good. Note sas seeds will repeat after 2**32-1 if I remember it correct.
You can write your own by finding out the random uniform generation.
%let n=50000;
data o;
seed=ceil(ranuni(123)*100) ;
do while(1);
call ranuni(seed, r3);
x= int(log10(seed));
if x<9 then do;
n+1;
id='a'||put(seed,z9.);
if seed<100000000 then c=1;
else if seed<200000000 then c=2;
else if seed<300000000 then c=3;
else if seed<400000000 then c=4;
else if seed<500000000 then c=5;
else if seed<600000000 then c=6;
else if seed<700000000 then c=7;
else if seed<800000000 then c=8;
else if seed<900000000 then c=9;
else c=10;
output;
if n=&n then stop;
end;
end;
run;
proc freq data=o;
table c;
run;
proc sort data=o nodupkey;by seed;run;