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-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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