BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Habs4Life
Calcite | Level 5

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

1 ACCEPTED SOLUTION

Accepted Solutions
ballardw
Super User

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.

View solution in original post

2 REPLIES 2
PGStats
Opal | Level 21

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
ballardw
Super User

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.

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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
  • 1111 views
  • 3 likes
  • 3 in conversation