/*Creating a Random Sample without Replacement*/
%macro randomsample(sizeno=,newdataset=,olddataset=);
data &newdataset(drop=obsleft sampsize);
sampsize=&sizeno;
obsleft=totobs;
do while(sampsize>0);
pickit+1;
if ranuni(0)<sampsize/obsleft then do;
set &olddataset point=pickit nobs=totobs;
output;
sampsize=sampsize-1;
end;
obsleft=obsleft-1;
end;
stop;
run;
%mend randomsample;
%randomsample(sizeno=200,newdataset=temp,olddataset=maps.africa) ;
是一个创建随机样本的代码,书上的,有个obsleft的变量,插在这里是干嘛用的哇。。看了许久,没看明白。。。
谢谢大虾们指教了