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

Hi,

 

I'm looking to extract 41,000 accounts out of my 200,000 account dataset using random sampling. I want the random sampling to be done based on the proportions of my 'band' variable, which has the following distribution:

0-<2441 makes up 15.63%

2449-20001 makes up 80.04%

200001-High makes up 4.33%

 

Please can someone tell me what code I could use to randomly get the 41,000 accounts I want based on the proportions (it's fine if the proportions are slightly different, as long as it equals 41,000 accounts)? In my example, the random sampling would mean about 6,150 in the 0-<2441 band, about 32,800 accounts in the 2449-20001 band, and about 1,640 accounts in the 200001-High band. I've seen proc surveyselect can be used (and I think proc sort of my accounts by 'band' might need to be done beforehand), but I'm not sure how to write the code to get what I require.

1 ACCEPTED SOLUTION

Accepted Solutions
sbxkoenk
SAS Super FREQ

You need proportional allocation as done here:

 

proc surveyselect data=Customers n=41000
                  out=SampleCust;
   strata BAND / alloc=prop ;
run;

Koen

View solution in original post

2 REPLIES 2
sbxkoenk
SAS Super FREQ

You need proportional allocation as done here:

 

proc surveyselect data=Customers n=41000
                  out=SampleCust;
   strata BAND / alloc=prop ;
run;

Koen

Justin9
Obsidian | Level 7
It worked, so thanks a lot for your code!

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