Data editing > Basic elements > Variables and arrays > Integer variables
 
Integer variables
Quick reference
To define an integer variable, type:
int var_name sizes
To refer to an integer variable, type:
name[cell_number]
More information
Integer variables store whole numbers. Strings of integer variables are called integer arrays, and each cell in the array may store any whole number from -1,073,741,824 to +1,073,741,823.
At the start of each run, Quantum provides an array of 200 integer variables called T. The first cell in this array is the integer variable t1 which may store any value within the given range; the second cell in the array is the integer variable called t2 which may also store any value within the given range.
To illustrate the difference between a data variable and an integer variable, suppose that your data contains the value of the respondent’s car to the nearest whole pound. If the value is £6,000, this takes up 4 columns in the data (assuming that you are concerned only with the digits); that is, four data variables, the first of which will contain the 6, and the other three of which will all contains zeroes.
If you place this same value in an integer variable, you need only one variable to store the whole value because each variable can store values in the range ±1,073,741,824.
Quantum provides an integer array of 200 integer variables. You can create your own arrays using statements similar to those shown above for data variables. Suppose you have a household survey in which you have collected the value of each car that the family owns. To set up an integer array in which to store each value, write:
int carval 10s
This creates an array called carval which contains ten separate integer variables called carval1 to carval10. The array size is followed by the letter s, so you can omit the parentheses from the individual variable names. Then you can copy the value of the first car into carval1, the value of the second car into carval2, and so on. If a particular household owns three cars values at £6,000, £2,500 and £500, then carval1 would have a value of 6,000, carval2 would be 2,500 and carval3 would be 500.
If you create your own integer variables, it is recommended that you name them with names that reflect their purpose in the run.
To find out more about creating and using named integer variables, see Creating new variables.
All integer variables have a value of zero at the start of a run, and they are not reset between respondents. If you want your integer variables to store information about the current record only, you must include statements in the edit to reset those variables to zero when a new record is read. For example, you might write:
carval1 = 0
at the start of the edit to reset the first integer variable of the carval array to zero.
Note You can also reset an integer variable to zero by using a clear statement. For more information about the clear statement, see Clearing variables.
T-variables with non-zero values are printed out at the end of the run.
See also
Variables and arrays