-
-
Save Ray4hz/4083348 to your computer and use it in GitHub Desktop.
Create random number along with the observation in the dataset
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
* 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