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
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.
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.
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.
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.
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.