NIPO ODIN Version 5.17

*PUT

Purpose

Puts data in variable.

Syntax

*PUT <var> <"text" | [value] | Qn | Qn,code | [expression] >

Description

Replaces the contents of a variable by data indicated in the second argument. This command is also allowed under condition. You can transfer the contents of a numeric variable to a text variable and vice versa.

When transferring the contents of a text variable to a numeric variable the text variable must contain a value. The following rules apply:

  • Any fractions are transferred as well.
  • The transfer stops at the first non-numerical character.
  • If the first character is not numeral the result value is 0.
  • When transferring the contents of a numeric variable to a text variable, it is rounded to the next integer, unless another format is specified with the *FORMAT command.

Arguments

var
This is an earlier defined variable, which receives the data.

text
Direct text enclosed in quotes (single or double) with eventually embedded contents of a variable. If quotes are to be displayed in the text use the other quotes to embed the text.

value
A value enclosed in square brackets.

Qn
The answer to the question will be used as data.

Qn,code
The code of a question is used as data. In a text variable the descriptive text of the code is used.

Qn,var
A code of question n is used as data. This code is defined in the variable var. In a text variable the descriptive text of the code is used, rather than the code number.

Qn,?R
A category of question n will be used as data. This code is defined by the repetition number. In a text variable the descriptive text of the code is used, rather than the code number.

expression
The result of the expression is stored in the variable.

Remarks

  • A text value may range several lines. All lines up until the closing of the quotes are considered part of the text. Line-feeds are also considered part of the text. If a closing quote is missing for a command, an error occurs during the syntax check.
  • A text may not contain NIPO ODIN commands other than the *? and *FONT (switching) directives.

Sample table

If a Sample table is used while copying positions from a T-file, the positions are translated towards their relative database field. For example:

*PUT intnr 52L8

Copies the interview number (position 52L8 in the T-file) in the variable intnr.

However, in this example a simple solution is also available:

*SAMPLEDATA intnr

This will automatically fill the variable intnr with the interview number from the Sample table.

Example 1

*VARS age
*QUESTION 1 *NUMBER 61L2
How old are you?

*PUT age Q1

In this example, the answer of question 1 is stored in the variable age.

Example 2

*TEXTVARS paper
*QUESTION 2 *CODES 61L7 *MULTI

Which of the following newspapers do you know?

1: La Repubblica
2: La Stanza
3: The Mirror
4: The New York Times
5: Le Figaro
6: La Libération
7: None *NMUL

*REPEAT 6
*IF [Q2,?R] *ELSE *GOTO 4
*PUT paper Q2,?R
*QUESTION 3 *CODES 1

How often do you read *?paper?

1: Daily
2: Once a week
3: Once a month
4: Don’t know

*QUESTION 4
*ENDREP

Example 3

*TEXTVARS sex
*QUESTION 7 *CODES 91

Gender?

1: Man *PUT sex "Men"
2: Woman *PUT sex "Women"

See Also