NIPO ODIN Version 5.17
Variables
You can store a text or a value in a variable to display in a question or to use for routing. Variables have to be defined with *VARS or *TEXTVARS before they may be used. Variable names are not case-sensitive.
A variable can be filled with the *PUT or the *SAVE command. Its contents can be displayed with the *? command. Note that the contents of the variable depends on the type of variable.
A numeric variable (*VARS ) may contain any value. Use the *FORMAT command to change the on-screen appearance of numeric values. When text or a text variable is saved in a numeric variable, the NIPO ODIN syntax check will give a warning message.
*TEXTVARS defines a text variable and may contain a text of unlimited length. The text may contain CR/LF which will be used when displaying the variable. Variables may not contain NIPO ODIN commands, except for *FONT .
Note: The contents of variables is not stored in the data file automatically. So make sure that if you base questions or routing on a variable, you store this information.
Example 1
*TEXTVARS Gender
*QUESTION 1 *CODES L1 *SAVE Gender Interviewer: Mark gender:
1: Male 2: Female
If code 1 is selected the text variable Gender will contain the text Male. If code 2 is selected, the variable Gender will contain the text 'Female'.
Example 2
*VARS Gender
*QUESTION 1 *CODES L1 *SAVE Gender Int. type gender of respondent
1: Male 2: Female
If code 1 is selected, the numeric variable Gender will contain the value 1. If code 2 is selected, the variable Gender will contain the value 2.
Example 3
*TEXTVARS Gender
*IF [ Q1,1 ] *PUT Gender "man" *ELSE *PUT Gender "woman"
If question 1 contains code 1, the variable Gender will contain the text 'man', else the variable Gender will contain the text 'woman'.
Example 4
*VARS Gender
*IF [ Q1,1 ] *PUT Gender "man" *ELSE *PUT Gender "woman"
The syntax check gives a warning message, because a text is written in a numeric variable. After the filter is checked, the contents of the variable will be 1 (regardless of the outcome of the filter).
Example 5
*VARS Age
*QUESTION 2 *NUMBER L2 *SAVE Age What is your age?
After question 2 is answered, the variable Age will contain the value that entered at Q2.
Example 6
*TEXTVARS Age
*QUESTION 2 *CODES L1 *SAVE Age What is your age?
1: 18 - 24 years 2: 25 - 34 years 3: 35 - 44 years 4: 45 - 54 years 5: 55 - 64 years 6: 65 years or older
9: won't tell
After question 2 is answered, the variable Age will contain the code text of the code that was selected.
Example 7
*VARS Age
*QUESTION 2 *CODES L1 *SAVE Age What is your age?
1: 18-24 years 2: 25-34 years 3: 35-44 years 4: 45-54 years 5: 55-64 years 6: 65 years or older
9: won't tell
After question 2 is answered, the variable Age will contain the code number of the code that was selected.
Example 8
*VARS Age,CurrentYear
*QUESTION 21 *NUMBER L4 *DUMMY *DATE Q21
*PUT CurrentYear [ Q21 ] *QUESTION 22 *NUMBER L4 *MIN 1900 *MAX [CurrentYear] *BUT 99 "Refusal" In what year are you born?
*IF [ Q3<>99 ] *PUT Age [ CurrentYear – Q22 ] *ELSE *PUT Age [99] *FORMAT 2.0
*QUESTION 23 *IF [ Age <> 99 ] So your age is *?Age years.
This example obviously is only true when the respondent already had his/her birthday.
Example 9
*VARS SelectBrand *TEXTVARS Brand
*QUESTION 31 *CODES L1 *DUMMY Here 3 brands are specified. The system will select 1 brand randomly.
1: Brand A 2: Brand B 3: Brand C
** Select a number below 3 and then add 1 to the result ** (this will randomly select 1 through 3) *PUT SelectBrand [ (RAN 3) + 1 ]
** Now put the category text of the dummy question in ** the text variable Brand *IF [ SelectBrand = 1 ] *PUT Brand Q31,1 *IF [ SelectBrand = 2 ] *PUT Brand Q31,2 *IF [ SelectBrand = 3 ] *PUT Brand Q31,3
** Now save the contents of SelectBrand in the datafile. ** If you forget to do this, you will not be able to know, ** which brand was selected in the analysis.
*COPY Q31 [ SelectBrand ]
|