Hello,
I have a dataset where individuals have observations across multiple rows. Patients are identified by their ID variable. Can I use proc surveyselect to randomly sample 100 of these unique IDs and then keep all of the rows that are tied to that id? It is almost like cluster sampling where the patient's ID is the cluster and we want to keep all of the individuals in that "cluster". I was having trouble finding anything like this in the documentation for proc surveyselect. If it is not possible to do with surveyselect, how can I do it using a different method (proc sql perhaps)?
This is what I've tried. I have also considered trying the selectall option, but that didn't work for me.
proc surveyselect data = data_set method = SRS sampsize = 100 seed = 12345 out = sample_ds; id _all_; strata id; run;
Thank you for any help you can provide!
You can use the SAMPLINGUNIT | CLUSTER statement in PROC SURVEYSELECT to select patient IDs instead of observations. For example, add
samplingunit patientID;
proc surveyselect data = data_set method = SRS
sampsize = 100 seed = 12345 out = sample_ds;
id _all_;
strata sart_id;
samplingunit patientID;
run;
You can use the SAMPLINGUNIT | CLUSTER statement in PROC SURVEYSELECT to select patient IDs instead of observations. For example, add
samplingunit patientID;
proc surveyselect data = data_set method = SRS
sampsize = 100 seed = 12345 out = sample_ds;
id _all_;
strata sart_id;
samplingunit patientID;
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 how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.