I am using proc surveyselect for unrestricted random sampling, my code is as follows:
proc surveyselect data=A out=B
seed = 1234 method = urs
sampsize=237 /* This is the number of rows of a dataset called C, which has already been created*/
outhits rep = 1;
run;
ods listing close;
My input datafile is called A and output datafile is called B.
I have another dataset called C (which is different from the input file A) and it has 237 rows, i.e., 237 observations for each variable. Instead of manually inputting the number 237, I want the sampsize to be equal to the number of rows of dataset C (since the number of rows of this dataset will change depending on the data I use). How can I do this?
Thanks
proc sql noprint;
select count(*) into :record_count
from c;
quit;
%put &record_count;
proc surveyselect data=a out=b
seed = 1234 method = urs
sampsize=&record_count /* This is the number of rows of a dataset called C, which has already been created*/
outhits rep = 1;
run;
Rather than sampsize use samprate=1
proc surveyselect data=sashelp.class out=class
seed = 1234 method = urs
samprate=1 /* This is the number of rows of a dataset called C, which has already been created*/
outhits rep = 1;
run;
But doesn't samprate=1 create a sample size equal to the size of the INPUT datafile? In my case, the input datafile is called "A", but I want the size to be equal to that of a datafile called "C", which is NOT the input data; they have different sizes.
How can I achieve this?
Thanks, this is what I was thinking of, however I am quite new to SAS. Any chance you can provide a skeleton template code for me to edit?
Cheers.
proc sql noprint;
select count(*) into :record_count
from c;
quit;
%put &record_count;
proc surveyselect data=a out=b
seed = 1234 method = urs
sampsize=&record_count /* This is the number of rows of a dataset called C, which has already been created*/
outhits rep = 1;
run;
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.
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.