Data editing > Basic elements > Variables and arrays > Real variables
 
Real variables
Quick reference
To define a real variable, type:
real var_name sizes
To refer to a real variable, type:
name[cell_number]
More information
You can define real variables and arrays to store real numbers with accuracy up to six significant figures. Values with more than six significant figures have the sixth figure rounded up or down according to the value of the extra figures.
For more information about real values, see Real numbers.
As with integer variables, the names of real variables should give some clue to the type of information they contain. Real arrays are created by statements of the form:
real liters 5s
This example creates a real array called liters which has five real variables named liters1 to liters5. It can store five real values, the first in liters1 and the fifth in liters5.
To find out more about creating and using named real variables, see Creating new variables.
Quantum also provides a set of 100 real variables named X which you can use.
Note All real variables start with a value of 0.0 and are not reset to zero between respondents.
For example, you data might contain information on how long, on average, each person in the household spent watching television during a given week. To manipulate these figures, you create an array of real variables in which to store the average viewing figures:
real tvwatch 8s
This provides room for up to eight people’s figures. If a household contains four people with viewing averages of 20.8 hours, 15.75 hours, 9.75 hours and 10.0 hours, then tvwatch1 will have a value of 20.8, tvwatch2 will have a value of 15.75, tvwatch3 will be 9.75 and tvwatch4 will be 10.0 hours. The rest of the variables in the array have values of 0.0.
Real variables with non-zero values at the end of the run are not printed out automatically. If you want to see these values, write them using a report statement. For more information about report, see Writing to a report file.
See also
Variables and arrays