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.

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

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.

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