Tables and axes > Introduction to axes > Defining conditions for an element
 
Defining conditions for an element
Quick reference
The general format of a condition is:
c=logical_expression
More information
Conditions define the characteristics a respondent must have in order to be included in a particular element. (At a higher level, they define which respondents are eligible for inclusion in a table or a group of tables.) Each element refers to one or more responses from the questionnaire, and you must identify both the columns in which the responses were coded and the codes assigned to those answers.
Take the question asking which color the respondent likes best. There are four choices, Red, Blue, Green and Yellow, coded 1, 2, 3 and 4 respectively in column 25 of card 1. This will generate four elements, one for each color. You need to find some way of telling Quantum that anyone with a 1 in column 25 of card 1 belongs in the first element, while anyone with a 4 should go in the fourth element.
Expressions describes various types of expression, one of which was the logical expression which returns a value of true or false. Statements of the form cn'p' were logical expressions since the expression is true if column n contains the code ‘p’ or false if it does not. This means that you can write c125’1’ to gather together all respondents having a ‘1’ code in column 25 of card 1 (remember that with multicard records the last two digits are the column number and any previous digits are the card type). If the respondent has a ‘1’ in this column, the expression is true. The respondent satisfies the condition for the element and is included in the counts for it. If there is no ‘1’ in c125 the expression is false and the respondent is rejected from the counts.
Having found a way of defining the condition, you now need to present it in a way that Quantum can understand. Quantum knows what c125’1’ means, but if you just write that by itself Quantum does not know what to do with it. To show that this defines a condition for an element, write c= (short for condition=) and then the expression, thus:
c=c125'1'
The general format of conditions is:
c=logical_expression
For information about the various forms a logical expression can take, see Logical expressions.
A condition can be any valid logical expression. The conditions are written exactly as they are in the edit. For example, a condition such as:
c=c234'12'
is read as an ‘or’ condition meaning that any respondent for whom column 234 contains code ‘1’ or code ‘2’ or both is eligible for inclusion in the element created by this condition. Any other codes in this column are ignored.
To specify that a respondent can be included if they have a specific code or set of codes only, use the form c=c234=’1’. This means that the respondent is added into the counts if c234 contains a ‘1’ and nothing else. Notice here that the statement contains two equals signs, one for the c= and one as part of the logical expression.
The logical expression c=c234n’12’ is used when the condition requires that the respondent does not have a ‘1’ or a ‘2’ or both in column 234.
The expression need not be restricted to single columns. It is quite correct to write:
c=c(121,123)=$101$
if you mean to gather respondents who have a ‘1’ in c121, a ‘0’ in c122 and a ‘1’ in c123. You might do this when items have been coded with numbers rather than codes; a 101 in c(121,123) could represent a 1971 Ford Escort car.
Other sorts of logical expression are valid as well. For example, the condition:
c=miles.gt.100
indicates that respondents are eligible for inclusion if the value of miles is greater than 100. The condition:
c=numb(c163,c171,c175).eq.1
only counts respondents having one code overall in columns 163, 171 and 175. This means that for a respondent to be eligible, one of those columns must be single-coded and the other two must be blank.
See
Special conditions
See also
Introduction to axes