«Anne Abelsæth Tutorial: Development of data entryand CAPI applications in CSPro Documents 19/2012 Anne Abelsæth Tutorial: Development of data ...»
Tutorial: Development of data entryand CAPI applications in CSPro
Tutorial: Development of data entry- and
CAPI applications in CSPro
Statistisk sentralbyrå • Statistics Norway
In this series, documentation, method descriptions, model descriptions and standards are published.
© Statistics Norway Symbols in tables Symbol Category not applicable.
When using material from this publication, Data not available..
Statistics Norway shall be quoted as the source.
Data not yet available …
Not for publication :
ISBN 978-82-537-8339-0 Printed version Nil ISBN 978-82-537-8340-6 Electronic version Less than 0.5 of unit employed 0 ISSN 1891-5906 Less than 0.05 of unit employed 0.0
Provisional or preliminary figure * Published March 2012 Break in the homogeneity of a vertical series — Break in the homogeneity of a horizontal series | Print: Statistics Norway Decimal punctuation mark.
Documents 19/2012 CSPro tutorial Preface Statistics Norway has for more than 15 years been involved in institutional development cooperation with sister-organisations. This work is based upon the professional competence and experience gained both in Norway and through the cooperation with several partners over these years. But in order to stay in front of statistical development we are trying to move ahead by developing and documenting new methods.
1.1. About this tutorial
1.2. Useful links and addresses
2. Creation of the example application
3. Creating the dictionary of Popstan Census Questionnaire
3.1. Identification elements
3.1.1. Creating the ID elements
3.1.2. Questions about the total number of persons in the Household
3.2. The Household record
3.2.1. A note on item labels and item names
3.2.2. Back to the household record
3.3. Adding value sets to the household questions
3.4. The population record
3.4.1. Creating the record holding the names of the household members
3.4.2. Creating the record containing details of the members of the household................ 16 4. More about creating dictionaries
4.1. More about the identification element and repeating records
4.1.1. Meaningless ID
4.1.2. IDs for repeating records – Record type
4.2. Viewing the Dictionary layout
4.3. Multiple value sets in the dictionary
4.3.1. Special values
4.4. Numeric Items with decimals
4.5. Relative versus absolute positioning: making dictionaries from existing files.......... 20 4.5.1. Absolute positioning
4.6. Documenting the Dictionary elements
4.7. Modifying the dictionary
4.7.1. Adding Fields to the Dictionary or Modifying item lengths after data entry has started
4.8. Dictionary Macros
4.8.1. Copy and paste dictionary items between CSPro and Excel
4.8.2. Generate sample or random data files
5. Creating the forms of the Popstan census questionnaire
5.1. General about forms
5.2. Adding questions to the form
5.3. Making the form look better
5.3.1. Order of execution of the elements in the form
5.3.2. Adding texts and boxes to the form
5.4. Adding CAPI questions and texts
5.5. Testing the application
5.6. More about the Data entry options window
5.6.1. Turning off the question about Operator ID
5.6.2. Partial save
5.6.3. System controlled vs. operator controlled applications
5.7. Creating the population forms
5.7.1. The form containing the names of the household members
5.7.2. The form containing the details of the household members
6. More about forms
6.1. Rosters in the forms
6.2. Field properties
6.3. Multiple languages in CAPI questions
7. Programming the Logic for the Popstan Census questionnaire
7.1. Getting started with programming
7.1.1. Declaration section – PROC GLOBAL
7.1.2. Procedural section
7.1.3. Commenting the code
7.1.4. Variables – and the option set explicit
7.2. Logic for the example questionnaire
7.2.1. Skips – logic for question H01
7.2.2. The If - then statement
7.2.3. This item ($) – referring to the current item programmatically
7.2.4. Compile the code
7.2.5. Showing the value set in a pop-up response box
Statistics Norway CSPro tutorial Documents 19/2012 7.2.6. Ending the interview in the middle of the questionnaire – logic for H02.................. 40 7.2.7. Stop adding data to a roster or a multiply-occurring form before reaching the end. 41 7.2.8. Checking validity of a date – using functions, arrays and boolean values............... 42 7.2.9. More about errMsg – error messages
7.2.10. The other skips in the questionnaire
7.2.11. More about skips
7.2.12. Keeping track of the persons of the household of the example questionnaire........ 48 7.3. Other logic checks for the example application
8. More about programming
8.1. Order of execution
8.2. Program loops
8.2.1. While loop
8.2.2. The Do loop
8.2.3. For loop
8.2.4. The Next- and break statements – Jumping to the next iteration of the loop – or out if it
8.3. Functions and operators
8.3.2. Numeric functions
8.3.3. String functions
8.3.4. Functions on records (multiple occurrence functions)
8.3.5. The global function OnKey() and execsystem()
8.4. End the whole data entry application – stop()
8.5. Multilingual CAPI applications
8.5.1. Multilingual error messages
8.5.2. Multilingual value sets – the setValueSets() function
8.6. setValueset() – programmatically change the value set
8.7. Trace – Makes debugging easier
9. Miscellaneous topics
9.1. Making the application ready to run on laptops/tablet PCs
9.1.1. Startup parameters: The.pff file and the sysparm() function
9.2. File types and folder structure
9.2.1. Structuring your files
9.3. Using lookup files
9.3.1. The dictionary of the lookup file
9.3.2. The main application
9.3.3. Using lookup files not in fixed format
9.4. Creating a menu application for multiple questionnaires
9.4.1. The dictionary
9.4.2. The Menu form(s)
9.4.3. The logic
Appendix A: Programming standards
Appendix B: Example questionnaire
6 Statistics Norway Documents 19/2012 CSPro tutorial
1. Introduction CSPro is a free software package used by hundreds of organizations and tens of thousands of individuals for entering, editing, tabulating, and disseminating census and survey data. CSPro is designed to be as user-friendly and easy to use as possible, yet powerful enough to handle the most complex applications. It can be used by a wide range of people, from non-technical staff assistants to senior demographers and programmers. The funding for CSPro comes from USAID.
CSPro is used by different institutions and organisations who do surveys. This includes National Statistical Offices, NGOs, Universities, Hospitals and businesses. It can be downloaded from the website of the U.S.
Census Bureau (See below for URL).
The most common kinds of surveys in which CSPro is used are censuses (population and housing; agriculture;
and economic), Demographic and labour force surveys, Household income and expenditure surveys, etc.
This document is meant as an introductionary tutorial for developing CAPI questionnaires (Computer Assisted Personal Interview) and data entry applications in CSPro, and does not cover all sides of the software package.
For a complete reference, please see the CSPro manual which can be downloaded from the U.S. Census Bureau’s website. This tutorial will cover the whole process of developing a CAPI questionnaire. This includes
• Defining the metadata for the survey as a CSPro dictionary (containing information about the questions, what kind of data will the answer be, name of the variable holding the data etc.)
• Defining the code lists (possible replies) to the given questions (for instance, a question about the respondent’s sex can have replies “1 = male” and “2 = female”)
• Designing the forms for the questionnaire.
• Programming the skips and controls and other logic of the questionnaire.
• Deploying the application on a laptop, tablet PC or similar.
The main areas of CSPro not covered in this tutorial are tabulation and batch editing data.
1.1. About this tutorial This tutorial will cover the whole process of developing a CAPI questionnaire. This includes The layout of the tutorial is in several parts: First the most common tasks when using CSPro are exemplified in the development of a simple census questionnaire, and some additional issues are discussed in the end of each chapter. The second part covers more complex, but still frequently used subjects.
The structure is the following:
• Development of the dictionary of the example application
• Discussion of topics about dictionaries not covered by the example
• Creation of forms for the example application
• Further discussion about forms
• Programming the logic of the example
• Further discussion about programming
• Miscellaneous topics
1.2. Useful links and addresses
• U.S. Census Bureau website: http://www.census.gov/ipc/www/cspro
• CSPro Users website: http://www.csprousers.org
• CSPro on Twitter: http://twitter.com/cspro
• Mailing list for CSPro questions: email@example.com
2. Creation of the example application We will use the questionnaire in the appendix B to create our CAPI application. The layout of the questionnaire is fairly common for a household survey: One part for identifying the household, one part with questions for the household as a whole, and then the third part for each of the members of the household.
We assume that you already have installed CSPro. If not, download it from the US Census Bureau website, and follow their instructions to download and install.
To create a new application, please start up CSPro, and tick “Create a new application”, then “OK”:
You then get a question about what kind of application you want to create. Select the default “Data Entry Application” and click “OK” again.
Then you have to give the application a location and a name (we chose the name popstan_census, and put it in a workshop folder somewhere convenient on the hard drive) Finally CSPro asks for the input dictionary. The default suggestion is a dictionary in the same folder and with the same name as the the application itself, only with the extension.dcf instead of.ent. (See chapter 9.2 for more about file extensions) One application can have several dictionaries. We will talk more about this in chapter 9.3. For now, accept the default dictionary and click “OK”. CSPro will then tell you that the dictionary does not exist, and ask you if you want to create it. Click “yes” to this.
CSPro has now created a skeleton for your application, which you can see in the left part of the CSPro window:
In the above picture, the first line on the left (having a blue book as the icon) is the dictionary itself. The next line is the questionnaire (or rather the level. An application can have more than one level). Then the ID of the record comes (this is the (Id items) line), and finally a record that CSPro has created for us named popstan_census record.
3. Creating the dictionary of Popstan Census Questionnaire In CSPro jargon, a dictionary is the place to store the questions and the metadata about the questions of a questionnaire: For each question we want the interviewer to ask (or the operator to enter in data entry applications), we need to decide
The dictionary is also important for deciding the flow of the data entry application:
• What parts of the questionnaire should be grouped together?
• Are there parts of the questionnaire that are to be repeated (e.g. one set of questions for the household, and one set of questions for each of the members of the household)?
• What variables do we want to use for identification of the different cases?
Every CSPro application needs at least one dictionary, but multiple applications can share the same dictionary, and a dictionary can exist without an application.
It is important to think through the flow and layout of the application at this stage. In our example questionnaire, it makes sense to have one record type containing the information about the household, and one record type containing information about the members of the household. And as a household can have many members, the latter record type has to be repeated several times, one for each member. But first we should decide what should be the identification elements.
3.1. Identification elements The identification elements are needed to uniquely identify the records or households in our survey. It is a good principle to keep the number of elements of the identification to a minimum.
In household surveys or censuses, the ID almost always consists of geographical data, for instance a combination of province, district, details about location within the district, and maybe a household number in the end. In other kinds of surveys there might be other indicators that uniquely identify the records depending on what kind of data to have entered.