/*generate random number from uniform distribution*/ /*for use in splitting the sample*/ data dataname2;/*new data with one extra column with name 'random'*/ set dataname1; /input data with name dataname1*/ /*generate a random order for each observation*/ /*8329 can be replaced by any number*/ seed=8329; random=ranuni(seed); run; /*split dataname2 into two datasets sample1 and sample2*/ /*in this example code, first 300 in sample1 and the rest in sample2*/ proc sort data=dataname2; by random; run; data dataname2 sample1 sample2; set dataname2; if _n_<301 then do; sample=1; output sample1; y1=y; /*y is the outcome(dependent) variable*/ end; else do; sample=2; output sample2; y2=y;/*y is the outcome(dependent) variable*/ end; output dataname2; run;