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;
Available on demand!
Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.
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.
Select SAS Training centers are offering in-person courses. View upcoming courses for: