Creating a Sample Data File

Other discussions about CSPro
Forum rules
New release: CSPro 8.0
Post Reply
Gregory Martin
Posts: 1777
Joined: December 5th, 2011, 11:27 pm
Location: Washington, DC

Creating a Sample Data File

Post by Gregory Martin »

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;
Post Reply