SAS Programming

DATA Step, Macro, Functions and more
BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
ishant
Calcite | Level 5

Hello Community,

 

I need to get a random sample of 500 records out of 1 million records in which I have SEGMENT_MANAGED is either YES OR NO but I want 20 % SEGMENT_MANAGED = YES(100 records) and 80% SEGMENT_MANAGED = NO(400 records). 

 

The code is given below that I have tried but this gave me 250 records (50%) each SEGMENT_MANAGED =YES or NO.:-

proc surveyselect data = WORK.nps_scrubbed_base_MOB
out= WORK.nps_sample_file_cad_MOB
method= srs
sampsize= 250;
strata SEGMENT_MANAGED;
run;

Could you please someone help me to find out how to do a random sampling with different weighted according to Strata??

1 ACCEPTED SOLUTION

Accepted Solutions
ballardw
Super User

Or , assumes your strata is variable is actually character. "No" would come before "Yes" so the first number on the SAMPSIZE list goes with the first strata value, the second with second value and so on. If your Strata variable is actually numeric then make sure you know which value is which so you can get the order correct.

 

proc surveyselect data = WORK.nps_scrubbed_base_MOB
    out= WORK.nps_sample_file_cad_MOB 
    method= srs
     sampsize= (400 100);
    strata SEGMENT_MANAGED;
run;

View solution in original post

2 REPLIES 2
ballardw
Super User

Or , assumes your strata is variable is actually character. "No" would come before "Yes" so the first number on the SAMPSIZE list goes with the first strata value, the second with second value and so on. If your Strata variable is actually numeric then make sure you know which value is which so you can get the order correct.

 

proc surveyselect data = WORK.nps_scrubbed_base_MOB
    out= WORK.nps_sample_file_cad_MOB 
    method= srs
     sampsize= (400 100);
    strata SEGMENT_MANAGED;
run;

sas-innovate-white.png

Special offer for SAS Communities members

Save $250 on SAS Innovate and get a free advance copy of the new SAS For Dummies book! Use the code "SASforDummies" to register. Don't miss out, May 6-9, in Orlando, Florida.

 

View the full agenda.

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 730 views
  • 1 like
  • 3 in conversation