If you want to create a simple sample data file (perhaps to test tabulations or edits instead of using the complete data file), you can create a small batch program to select cases to output. For instance, this program selects every twentieth case to generate a 5% sample:
PROC GLOBAL
numeric samplePercentage = 5;
numeric caseCount = 0;
PROC CREATESAMPLE_QUEST
preproc
inc(caseCount);
if caseCount = ( 100 / samplePercentage ) then
caseCount = 0;
else
skip case;
endif;
Alternatively, you can use the random function to generate a sample file that does not choose every nth case. Remember to call the seed function before using the random function.
if random(1,100 / samplePercentage) <> 1 then
skip case;
endif;
No comments:
Post a Comment