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;
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.