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??
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;
Use a dataset as SAMPSIZE= option, as described here
https://documentation.sas.com/doc/en/statug/15.2/statug_surveyselect_details25.htm
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;
Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!
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.
Ready to level-up your skills? Choose your own adventure.