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

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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
  • 1283 views
  • 6 likes
  • 3 in conversation