BookmarkSubscribeRSS Feed
ajbarla
Fluorite | Level 6

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 

 

 

4 REPLIES 4
user24feb
Barite | Level 11

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;
ajbarla
Fluorite | Level 6

what happens when '=' is used ?

user24feb
Barite | Level 11

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.

stat_sas
Ammonite | Level 13

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;

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!

What is Bayesian Analysis?

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 4 replies
  • 1705 views
  • 6 likes
  • 3 in conversation