Solved
Contributor
Posts: 24

# Random sampling in Deciles

Hi I have a dataset which has 2200 company IDs (CMIECODE) and I have cut the 2200 companies into 10 deciles based on capital so there will be 220 companies under each decile. I would like to randomly pick 50 companies under each decile so my output dataset will contain 500 companies (50 * 10). I could number each company the decile rankings but could someone help me to randomly select 50 companies in each decile my sample input dataset looks as below I have used the below code to compute random sample for 50 companies out of 2200.

CMIECODEMarketCapDecile

12

50005
1360004
14100001
1550010
1620010

PROC SURVEYSELECT DATA = CRSP2 OUT = CRSP3 METHOD =SRS

SAMPSIZE = 50 seed = 12345 NOPRINT;

ID CMIECODE;

RUN;

Accepted Solutions
Solution
‎03-17-2015 10:14 PM
Posts: 5,482

## Re: Random sampling in Deciles

Use the STRATA statement:

proc sort data=CRSP2; by Decile; run;   /* Required */

PROC SURVEYSELECT DATA = CRSP2 OUT = CRSP3 METHOD =SRS

SAMPSIZE = 50 seed = 12345;

strata Decile;

ID CMIECODE;

RUN;

PG

PG

All Replies
Posts: 3,167

## Re: Random sampling in Deciles

You are close. Please RTM, STRATA statement under Proc SurveySelect.

Solution
‎03-17-2015 10:14 PM
Posts: 5,482

## Re: Random sampling in Deciles

Use the STRATA statement:

proc sort data=CRSP2; by Decile; run;   /* Required */

PROC SURVEYSELECT DATA = CRSP2 OUT = CRSP3 METHOD =SRS

SAMPSIZE = 50 seed = 12345;

strata Decile;

ID CMIECODE;

RUN;

PG

PG
🔒 This topic is solved and locked.