Hello,
I'm trying to sample data into development sample and validation sample using proc surveyselect, but the output shown is not sampled returning the same original dataset.The code I used is
proc surveyselect data=stores1 out=devsample method=srs samprate=0.5 outall;
run;
I also used ranuni function but the result is same , no sampling is done
data devsample;
set stores1;
if ranuni(100)<0.50 then output=devsample;
run;
please correct me where I went wrong
Both seem o.k. (remove "=" from the 2nd program). Do you get an error? Could stores1 be empty? ..
Data Stores1;
Do ID1=1 To 30;
Do ID2=1 To 30;
Value=Ranuni(1);
Output;
End;
End;
Run;
proc surveyselect data=stores1 out=devsample method=srs samprate=0.5 outall;
run;
data devsample2;
set stores1;
if ranuni(100)<0.50 then output devsample2; * remove equal sign!;
run;
what happens when '=' is used ?
If you use '=', you create a variable with the name 'output'. Then a second variable is created with the file name 'devsample'. Because there are no entries for 'devsample', in effect you are creating 2 variables with missing values, and write it to the (/all) data files declared in the DATA-statement at the beginning.
Hi,
proc surveyselect data=stores1 out=devsample method=srs samprate=0.5 outall;
run;
outall option creates a variable "selected" that provides a flag to separate two data sets. You need a data step to create two data sets. Please try this after proc surveyselect:
data develop validate;
set devsample;
if selected then output develop;
else output validate;
run;
Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.
Register today!Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.
Select SAS Training centers are offering in-person courses. View upcoming courses for: