Skip to content

Instantly share code, notes, and snippets.

@Ray4hz
Created November 16, 2012 02:18
Show Gist options
  • Save Ray4hz/4083348 to your computer and use it in GitHub Desktop.
Save Ray4hz/4083348 to your computer and use it in GitHub Desktop.
Create random number along with the observation in the dataset
* create random number in a dataset according to its obs;
%macro setr(indsn=, outdsn=, rn=);
%let dsid = %sysfunc(open(&indsn));
%global nobs;
%let nobs = %sysfunc(attrn(&dsid, nlobs));
%let rc = %sysfunc(close(&dsid));
data tem;
set &indsn;
rnum&rn = _n_;
run;
proc plan seed = &rn;
factors rnum&rn = &nobs/noprint;
output data = tem out = &outdsn;
run;
%mend;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment