Solved
New Contributor
Posts: 2

# Sampling Question

proc surveyselect data=SORTMARCH2012DATA

method=srs n=2

seed=1979 out=MarchTrackingIDSample;

strata TrackingIDLength;

run;

I have a table of barcode scans. I am analysing the length of the barcodes scanned. The code above gives me 2 random samples for each Barcode length in the data. I would like to have 5 random samples for each Barcode length (where possible), however cannot make n=5 because there are only 2 instances of some Barcode lengths(resulting in a script failure). Does anyone know how to get around this limitation?

Thanks for your time,

James

Accepted Solutions
Solution
‎03-22-2012 05:04 PM
Super User
Posts: 13,523

## Sampling Question

Posted in reply to Habs4Life

Since you are using a STRATA statement you have the option of using SAMPSIZE in the proc statement.

such as SAMPSIZE = (5 5 5 2 5 5 2 5 5)

The samplesize is then PER strata corresponding to the sorted order of the strata. In my exampe the 4th and 7th Strata are the ones that only have 2 samples.

All Replies
Posts: 5,524

## Re: Sampling Question

Posted in reply to Habs4Life

I think this would work :

proc sql;
create table strataSampleSizes as
select TrackingIDLength, min(count(*), 5) as _NSIZE_ from SORTMARCH2012DATA
group by TrackingIDLength;

proc surveyselect data=SORTMARCH2012DATA
method=srs N=strataSampleSizes
seed=1979 out=MarchTrackingIDSample;
strata TrackingIDLength;
run;

PG

PG Corrected the code.

PG
Solution
‎03-22-2012 05:04 PM
Super User
Posts: 13,523

## Sampling Question

Posted in reply to Habs4Life

Since you are using a STRATA statement you have the option of using SAMPSIZE in the proc statement.

such as SAMPSIZE = (5 5 5 2 5 5 2 5 5)

The samplesize is then PER strata corresponding to the sorted order of the strata. In my exampe the 4th and 7th Strata are the ones that only have 2 samples.

🔒 This topic is solved and locked.

Need further help from the community? Please ask a new question.

Discussion stats
• 2 replies
• 178 views
• 3 likes
• 3 in conversation