Data editing > Changing the contents of a variable > Assignment statements > Storing arithmetic values > Columns
 
Columns
Columns can also store arithmetic information, but unlike other variables they have a predefined size which means they can only store numbers of a certain size. For example, c(1,10) can store numbers of up to ten digits whereas c(1,3) only stores numbers of up to three digits.
If the number is negative, Quantum puts the minus sign in the column immediately to the left of the first digit, but if there are no spare columns the first digit is dropped and the minus sign put in the left column. If t5=-278, the statement:
c(46,49)=t5 gives 4----+----5
-278
but:
c(47,49)=t5 yields 4----+----5
-78
This does not apply to negative numbers whose length exceeds the field width by more than one character. Then, the number is copied into the field from the right and the minus sign and any excess digits are ignored. Thus, if t5=-1278, c(42,44) contains the number 278.
If the value to be saved has fewer digits than there are columns in the field, it is right-justified in the field and the remaining columns padded with zeros.
Here are some more examples:
/* Room to store values of t60 between –99 and +999
c(110,112)=t60
/* visits*4 should be between –999 and +9999, otherwise truncated
c(34,37)=visits*4
/* Result never truncated since maximum value is 81
c(10,11)=c7*c8
/* Total holidays taken
c(224,230)=home + abroad
/* Count the number of codes
pch=numb(c21,c22,c23'1/5',c24'1/9')
When copying real numbers into columns, Quantum needs to know how many decimal places are required. This is done by following the variable with a colon and a digit defining the number of places. For example, if x5=10.22, the statement:
cx(15,19):2=x5
results in:
----+----2----
10.22
If the real number has more decimal places than you have allowed for, say 3 instead of 2, the extra decimal places will be ignored.
See also
Storing arithmetic values