About Me

My photo
Over nine years of research experience in social science and public health research, who specializes large scale survey design and analysis, and data quality in various forms and tools of research work with Quantitative as well as Qualitative techniques and then last five years I have developed data entry and tabulation package in CSPro for various large scale surveys in India as well outside India. Presently I am working as Consultant State Data Manager in UNICEF Chhattisgarh (Through PDCSL).

Tuesday, April 5, 2011

Creating a Sample Data File

visit counter for blogspot

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