04-17-2013 12:15 PM
I have a very large dataset of clients with their ages and other attributes. Would it be possible to extract a set of records from this larger dataset such that the subset had a mean of say 55 years of age and a standard deviation of 2?
04-17-2013 01:35 PM
If I had to do this I would be tempted to use proc survey select with age as the stratum variable. Put different sizes for each strata (age) such that the result would have your desired mean and deviation with a total size that you want.
I see a certain amount of trial and error as even for a given total number of records there many ways to meet your requirement.
You might simplify code by restricting ages first to something like 45 to 65 to reduce the number of strata to use.
Hint if you use this method you probably should set a seed value so you can duplicate the data later if needed.
I would start with a trial data set of age and a weight variable and run them through proc means to get an idea of the numbers I want as the strata counts for the data shape and range I want to use later.
04-17-2013 02:18 PM
I agree with @Ballardw. You can use the PDF function to determine what percentage to extract for each age stratum. For details and an example, see Construct normal data from summary statistics - The DO Loop
04-17-2013 03:41 PM
After lunch and improved blood sugar I remembered we could generate a normal as specified. This will generate a data set to use with Proc SurveySelect as the SampSize option. Pick i in the do loop to match your desired size AND verify that the raw data set has at least as many persons with age for each as the _nsize_ values. This is intended to work with SRS sampling without replacement. Or you can generate sampling fractions.
do i = 1 to 5000;
x = round((rand('NORMAL',55,2)),1);
proc freq data=junk noprint;
table x / out=SampleSize (rename=(count=_nsize_) drop=percent);