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.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.