06-25-2014 02:06 PM
Utilizing proc Survey select I am trying to get a random
sample of 10 records per dataset I have created.
Each data set has been created based on specific criteria.
Unfortunately we will be running qtrly and each data set will not always have
10 records to choose from and in some instances may have not data at all. How
can I update my code to select N=10 and when there are less than 10 records it
pull all available?
Within specific datasets the random sample needs to include
a Strata Variable. I would also like to have 10 records pulled total but broken
out evenly between the strata, it is currently pulling proportionally.
06-25-2014 02:14 PM
One start would be to post the code currently using (or generated by EG).
Generally to select per stratum your Sampsize option has one value per stratum. If you have varying number of strata and records per strata you're going to need to 1) determine # strata per data set, 2) calculate sampsize per strata 3) determine total records and records per strata and pass parameters to surveyselect. This sounds like it may be a requirement for some macro programming.
The ALLOC option may help with some.
06-25-2014 02:36 PM
Below is the code in its current state.
how can it be updated that I can get an even number of strata (right now AllLOC=Prop and I am getting 9 records for one strata and 1 for the other due to source proportion. I would like even break out so in this case with N=10 it would be 5 each. The below is specific to one dataset that has enough records to choose from but some of the other datasets do not.
_CLIENTTASKFILTER = status = 'Approved';
DATA=WORK.MMC_FHP( WHERE=(status = 'Approved') )
STRATA benefit_plan / ALLOC=PROP;
06-25-2014 05:58 PM
To get two strata with equal numbers of samples:
STRATA benefit_plan / ;
You may want to look at the secondary dataset option in surveyselect as you can calculate such things as the number of strata and sample per strata and get them into a data set for parameters.