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

I need to select 3000 cases from about 63000 cases, by stratefying 3 variables:

age: continuous. what to have similar mean/std in the selected 3000 and the total sample.

gender: binary. want to have similar percentages in the selected 3000 and in the total sample

location: binary. two levels. what to have similar percentage in selected 3000 and in the total.

 

I am not sure if the following code is right or not. Can I use both categorical and numeric variables for strata ?

 

proc surveyselect data = total_sample out = selected_3000 
    method = srs n=3000 seed = 9876;
    strata gender age location;
run;

 

1 ACCEPTED SOLUTION

Accepted Solutions
PGStats
Opal | Level 21

Simple random sampling will give you the correct proportions (gender, location) and average (age) without stratification. Stratification is for when you want your selected sample to represent a population that is not necessarily well represented in your sampling set. Try this:

 

/* Option outall creates a variable named Selected = 1 when selected in the
sample and = 0 otherwise. */
proc surveyselect data = total_sample out = selected_3000 
    method = srs n=3000 seed = 9876 outall;
run;

/* Check proportions */
proc freq data=selected_3000;
tables selected*(gender location) / chisq;
run;

/* Check age averages */
proc glm data=selected_3000;
class selected;
model age =  selected;
run;

(untested)

PG

View solution in original post

3 REPLIES 3
ballardw
Super User

Surveyselect with Strata variables selectes sample size indicated for each level of the strata level. So an actual continuous variable is a poor choice for strata. What is the TOTAL number of records you are trying to select? I can't tell if you want 9000, 15000 or 3000 or something different.

I am not sure what you mean by "in the selected 3000 and the total sample".

 

You might try leaving out the strata and see if the summary of the resulting data is close enough for your purpose.

PGStats
Opal | Level 21

Simple random sampling will give you the correct proportions (gender, location) and average (age) without stratification. Stratification is for when you want your selected sample to represent a population that is not necessarily well represented in your sampling set. Try this:

 

/* Option outall creates a variable named Selected = 1 when selected in the
sample and = 0 otherwise. */
proc surveyselect data = total_sample out = selected_3000 
    method = srs n=3000 seed = 9876 outall;
run;

/* Check proportions */
proc freq data=selected_3000;
tables selected*(gender location) / chisq;
run;

/* Check age averages */
proc glm data=selected_3000;
class selected;
model age =  selected;
run;

(untested)

PG
fengyuwuzu
Pyrite | Level 9
The "outall" option is really great. I was thinking to merge back to create such an indicator variable.

sas-innovate-2024.png

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.

 

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
  • 3 replies
  • 865 views
  • 0 likes
  • 3 in conversation