4 More about axes
4.1 The col statement
Quick Reference
To define a list of elements with codes all in the same column, type:
col number;[base;] elm_txt1[=’codes1’] [;elm_txt2[=’codes2’] ... ]
If several consecutive statements in an axis have conditions defined by a code or codes in the same column, you can save yourself a lot of time and effort by replacing the individual n01 statements with a single col statement.
One of the simplest col statements you can write is:
col n;[base];Rtext1[=’p1’];Rtext2[=’p2’]
where n is the column containing the codes for this question, base creates a base element, and Rtext1=’p1’, Rtext2=’p2’ and so on define the texts and conditions for the individual elements.
To explain more clearly how the col statement works, let’s take the axis mstat that we wrote earlier and rewrite it using a col statement. Originally it consisted of five statements:
n10Base
n01Single;c=c109’1’
n01Married;c=c109’2’
n01Divorced;c=c109’3’
n01Widowed;c=c109’4’
We can replace these with the line:
col 109;Base;Single;Married;Divorced;Widowed
The texts Single, Married, Divorced and Widowed define the element texts and their positions in the statement tell Quantum which code represents which response.
Quantum User’s Guide Volume 2
84 / More about axes – Chapter 4
When Quantum encounters a col statement which just contains element texts, it assumes that those responses are single-coded in the order 1234567890–& and blank. Thus, in our example, Single is the first element so it is assumed to be a code ‘1’ in column 109; Widowed is the fourth element so it is assumed to be a code ‘4’ in column 109.
Suppose we want to print the elements in mstat in a different order, say, Widowed, Single, Married, Divorced. We can either write each response followed by its code, thus:
col 109;Base;Widowed=4;Single=1;Married=2;Divorced=3
or we can just define the code for Widowed and let Quantum assign the other codes by default. The default for the first response without a specific code is ‘1’:
col 109;Base;Widowed=4;Single;Married;Divorced
However, if automatic coding has been specified, and then a single element is assigned a specific code, the remaining codes continue from where the automatic numbering left off. Therefore, if the above axis was specified as:
col 109;Base;Widowed;Single;Married=6;Divorced
the first element is Widowed, so it is assigned code ‘1’, Single is code ‘2’, Married is specifically given the code ‘6’, and Divorced reverts to the automatic numbering and is given code ‘3’.
The code list for col consists of 12 codes followed by blank. This means that blank is the 13th code in the list. If a col statement lists 13 responses, the code for the 13th response is blank. For example:
col 234;Base;Brand 1;Brand 2;Brand 3;Brand 4;Brand 5;Brand 6;
+Brand 7;Brand 8;Brand 9;Brand 10;Brand 11;Brand 12;Brand 13 The condition that Quantum applies for Brand 13 is c224’ ’.
Codes may be combined to form ‘or’ conditions, just as on n01 statements. If the condition for an element is one code only, the code may be written without the single quotes. Obviously this does not apply when the code is a blank: blanks must always be enclosed in single quotes. Here’s an example showing both ways of entering codes:
col 109;Base;Divorced/Widowed=’34’;Single=1;Married=2
This statement creates four elements; a base for everyone eligible for inclusion in the table, and elements for single people, married people and respondents who are divorced or widowed.
Codes on col statements need not be exclusive. For example, you may write:
col 110;Base;All Colors (Net)=’1/4’;Red;Blue;Green;Yellow to create a net for a multicoded response.
Quantum User’s Guide Volume 2
More about axes – Chapter 4 / 85 You can use a user-defined data array element in place of a column in the C array. You type the variable name and the number of the column containing the data.
For example:
col color(1);Base;First choice (Net)=’1/4’;Red;Blue;Green; . . . col color(2);Base;Second choice (Net)=’1/4’;Red;Blue;Green; . . .
The respondent’s first choice is read from column 1 of the color array, and the second choice is read from column 2 of the same array.
✎
You are advised to enter codes for all responses in the list if the code order is anything other than 1234567890-& blank. That way you will know exactly which code represents which response straight away rather than having to look to see which codes have been assigned elsewhere.Take care if the element text contains a semicolon. Semicolons separate the individual responses on a col statement, so if you want a semicolon to be printed as part of a text, precede it with a backslash. When the text is printed, the backslash will be replaced by a space. For example:
col 157;Base;One;Two;Three;Four creates five rows, but:
col 157;Base;One\;Two=’12’;Three\;Four=’34’
generates three rows, the second of which has the text ‘One ;Two’ and the third of which is
‘Three ;Four’.
Continuing col statements
Col statements may be continued using a + in column 1 of the next line. If a response will not fit on the current line, you can split the statement after a semicolon separating two responses.
The continuation must not occur within a set of semicolons otherwise Quantum assumes that the continued parameter is, in fact, two items not one. For example:
col 121;Base;Inner London=1;Outer London=2;England +Outside London=3
creates five rows — Base, Inner London, Outer London, England, and Outside London, which is not what we want, but:
col 121;Base;Inner London=1;Outer London=2;
+England Outside London=3
creates four rows, the last being England Outside London.
Quantum User’s Guide Volume 2
86 / More about axes – Chapter 4
Dealing with don’t knows
Quick Reference
To create an element on a col statement that counts respondents present in the base but not in any other element since then, type:
col number; ... ; element_text=rej
In chapter 3, ‘Introduction to axes’ we described how to deal with Don’t Knows using the notation c=– on the n01 statement. To achieve the same thing on a col statement, we use the keyword =rej:
col 121;Base;Inner London;Outer London;England Outside London;
+Scotland and Wales=’45’;Don’t Know/Not Answered=rej
In this example the row entitled ‘Don’t Know/Not Answered’ will include all respondents for whom c121 is blank or contains any code other than ‘1/5’. As with c=–, rej checks back to the previous Base or, if there is no base, to the beginning of the table.
If an axis contains two col statements, the first containing the word Base and the second containing the keyword rej but no base, the line with rej will contain anyone not already included by either statement.
Conditions on col statements
Quick Reference
To include a respondent in an element if the column contains codes for that element and no other, type:
col =number; ...
The condition on an n01 statement can be any valid logical expression. This is not true for the col statement which can be used only when the conditions can be represented by the codes of one column. Nevertheless, the flexibility of col is somewhat increased by the fact that you can type = before the column number to mean ‘exactly equal to’. This is the same as writing a logical expression using cn=’p’.
☞
For further information about the = operator in logical expressions, see ‘Comparing data variables and data constants’ in chapter 5, ‘Expressions’ in the Quantum User’s Guide Volume 1.For further information about conditions on n01 statements, see section 3.3, ‘Defining conditions for an element’ in this volume.
Quantum User’s Guide Volume 2
More about axes – Chapter 4 / 87 Suppose c114 contains information about the ages of children in the household as follows:
If the household contains children in more than one age group, the column will be multicoded. You may wish to set up a table for people whose children are in one age group only; that is, they may have any number of children but they must all be under 5 or all aged 5 to 10; people with one child under five and one aged between 5 and 10 will be ignored. We would set up our table as:
l child1
col =114;Base;Under 5;Aged 5-10;Aged 11-15;Aged 16-18
The = includes respondents who have the specified code and no other codes in c114. It is the same as writing the condition c=c114=’1’. The first row after the base will be a count of all households having children under 5 only; the next row will tell us how many households have children aged 5 to 10 only.
Bases on col statements
Quick Reference
To define a base element on a col statement, type:
col number;base[=text]; ...
If the keyword base is given by itself, the base element will be labeled ‘Base’.
The keyword base creates a base row or column with the text Base, the text being printed exactly as it appears on the col statement. To have a base with a different text, follow the keyword base with an equals sign and the desired text. For example:
col 230;base=All Using Brand A
will print a base row with the text ‘All Using Brand A’.
Tables may also be weighted in which case any base created with base or base= will also be weighted.
☞
For information on weighting, see chapter 1, ‘Weighting’ in the Quantum User’s Guide Volume 3.(c114)
Under 5 years 1
5 - 10 years 2
11 - 15 years 3
16 - 18 years 4
Quantum User’s Guide Volume 2
88 / More about axes – Chapter 4
Subheadings with col
Quick Reference
To define a subheading element on a col statement, type:
col number; hd=subheading_text; ...
The hd= option on a col statement performs the same task as an n23 in the axis. To create the axis heading ‘Marital Status’ with hd= on a col statement, we would write:
col 109;Base;hd=Marital Status;Single;Married;Divorced;Widowed
Text-only elements with col
Quick Reference
To define a text-only element on a col statement, type:
col number; tx=text ...
The option:
tx=text
on a col statement creates a text-only element in the axis in the same way that an n03 element does.
For example:
col 138;Base;hd=Color Preferred;tx=Primary;Red;Blue;Yellow;
++tx=Pastel;Pink;Lilac
When this axis forms the rows of a table, the two tx elements form text-only rows defining the types of colors which follow. When the axis is used as the columns of the table, the tx= elements are ignored.
Quantum User’s Guide Volume 2
More about axes – Chapter 4 / 89