BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
awardell
Obsidian | Level 7

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!

 

1 ACCEPTED SOLUTION

Accepted Solutions
Watts
SAS Employee

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;

 

View solution in original post

2 REPLIES 2
Watts
SAS Employee

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;

 

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

How to Concatenate Values

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.

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
  • 2 replies
  • 1875 views
  • 2 likes
  • 2 in conversation