220 likes | 459 Views
MICS Data Processing Workshop. CSPRO Applications. Creating a Data Entry Application. We’ll now create a data entry application The application will make use of the test dictionary and form Before creating the application, I’ll briefly discuss order of operations in CSPRO data entry path
E N D
MICS Data Processing Workshop CSPRO Applications
Creating a Data Entry Application • We’ll now create a data entry application • The application will make use of the test dictionary and form • Before creating the application, I’ll briefly discuss • order of operations in CSPRO • data entry path • most common data entry commands
CSPRO Procedure Types • Global procedure (proc global) • logic executed when application begins/ends • Form file procedure (proc form_file_name) • logic executed before/after each case • Level procedure (proc level_name) • logic executed before/after level • group procedure (proc group_name) • logic executed before/after a form or roster • variable procedure (proc variable_name) • logic executed before/after variable’s field entered
Preproc and Postproc • Procedures are broken into two parts • Preproc • logic executed before item • for example, skip a variable • Postproc • logic executed after item • for example, check if data entered is consistent • for example, skip to a variable • If no explicit statement, logic is in the postproc by default
Order of Operations • Global proc • Form file preproc • Level 1 preproc • Form 1.1 preproc • Field 1.1.1 preproc • Field 1.1.1 postproc • ...other form 1 fields • Form 1.1 postproc • ...other level 1 forms • Level 2 preproc • Form 2.1 preproc • Field2.1.1 preproc • Field 2.1.1 postproc • Form 2.1 postproc • ...other level 2 forms • Level 2 postproc • Level 1 postproc • Form file postproc
The Data Entry Path • The data entry path contains all of the questions that a respondent should be asked • It is determined by • the type of the questionnaire • the responses to questions in conjunction with • questionnaire skips • questionnaire filters
Controlling the Data Entry Path • CSPRO allows one to control completely the data entry path • The first step is to • open DE application • go to options --> data entry • select system controlled • (while you are there, make all alphanumeric variables upper case)
Questionnaire Skips • CSPRO has 2 ways of implementing skips • The skip to command • if the variable being skipped to is in a single record • To skip to a variable or group use skip to variable_name; skip to group_name; • The skip to next command • if the var. being skipped to is in a multiple record
Reentering • To force the data entry operator to reenter a field (e.g., if the data entered are inconsistent) use reenter;
if command • Use to check for a condition: if HH9 <> 1 then skip to HH16; endif; if not HH6 in 1,2 then reenter; endif;
Ending a Level • You must manually end a level if • the last variable in the data path is not the last variable on the questionnaire • you have entered the last woman or under-five questionnaire • This is accomplished using the endlevel command
The ENDLEVEL Command • The effect of the endlevel command depends upon its context • In field/roster/form proc, passes control to the level postproc • In level preproc or postproc, passes control to postproc of next highest level • In postproc of level 1, pass control to the form file’s postproc
Ending a Group • A group is a record or roster • A group is ended by the endgroup command • The effect of the command depends upon context: • In an item procedure, passes control to the current group’s postproc • In the preproc of the group, skips the entire group and passes control to the group’s postproc
Working Variables • Working variables must be declared in the global procedure • Numeric working variables can be declared together • numeric var1 var2; • Alphanumeric working variables are declared separately • alpha(length) avar1; • alpha(length) avar2;
Setting Parameters • Global parameters should be declared in the preproc of the forms procedure • e.g., minimum age at first birth • Assign a value to a working variable created for the purpose • Comment your parameter using braces • For example • minab = 144; {minimum age at first birth in months}
Recoding Variables • To recode variables, use the recode command • The following logic recodes women’s age into groups recode WM9 => agegrps; 15-19 => 1; 20-24 => 2; => 3; endrecode;
Generating Error Messages • If the cluster number is invalid, the following code will display an error message errmsg(0010);
Providing an Error Message • Error messages must have user-defined text to be effective • For the preceding example, one would add a line 0010 cluster number invalid • To view the error message file • to do so, right click on the message tab while editing a procedure’s logic
Error Message Parameters • The values of any variables listed after the error message number will be passed to the error message • Parameters are displayed in the error message using • %d for numeric values • %s for alphanumeric values
Creating the Application • Select file --> new • Select object type data entry application • Use file name: test • Use folder: c:\mics\cspro\test • Click next • Click yes when prompted to use the test form • Click finish
Modifying the Application • Add logic to • check the household number is consistent • display message and data entry if not • implement the region skip • check the date of interview is consistent • display message and require reentry if not • Compile and then save your application
Testing the Application • Click once on execute button on toolbar (traffic light) • Use nodata.dat datafile • Enter a case