Você está na página 1de 42

Session 3 Basic Tabulation Elements

Core Skills for Data Processing ORSC 2004 - Internal Training

1 1

Core Skill Training Session Six: Data Analysis

Objective At the end of the training program, participants should be able to understand

Run control statements Table control statements Axes control statements Defining axis using various methods Defining breaks using g&p statements and heading levels

The hierarchy
Tabulation section consists of three sets of control statements, viz.,

Run Control Statements

Table

Control Statements

Axis Control Statements

Run Control Statements

Run control statements


Determine the overall characteristics of the run
Contain the text which is constant for all tables.

Filters may be defined, applicable either to all tables in the run or to all tables defined before another general filter statement is read.
Titles are entered in various ways depending upon their position in the table. Footnote text is defined which is constant for all the tables in the run These statements are also called as a statement options

Run control options


Options can be divided into two categories:

Output options Data options

Output options determine the format of each table in the run, but have nothing to do with the numbers in each cell Data options determine how the cell counts are to be created but have nothing to do with the overall appearance of the tables

Some useful output options


Csort Date
Column Sort: Sort the columns of the table Todays date: Prints the current date in the top of right-hand corner of each table Dec= Decimals: Determines the number of decimal places for absolutes. No decimal places by default. Decp= Decimals in percentages: Sets the number of decimal places for percentages. The default is one decimal place. Dsp Double Spacing: Leaves one blank line between each row of the table. Flush Percents, flush: Rows containing percentages are printed with percentages directly below absolutes instead of one character to the right. Font=() Fonts for laser printing. Nzrow Suppresses the printing of rows where all cells are zero or round to zero Nzcol Suppresses the printing of columns where all cells are zero or round to zero

Some useful output options


Means Op=
Page Paglen= Pagwid= Pc Pcsort Scale= Side= Produces tables of the mean values of the inc variables Determines the type of output received. More than one type may be requested, in which case each row consists of all types. Invokes automatic page number Determines the number of lines printed on each page. Default is paglen=60 Specifies the page width if other than 132 characters. May be up to 199 characters wide. Default is pagwid=132 Percent signs are printed after percentage figures. This is the default Sort tables on percentages rather than absolutes Multiplies (scale=n) or divides (scale=/n) all cells in the tables by a given value Specifies the row text width. Maximum is side=120, default is 24 characters

Some useful output options


Sort Spechar
Stat= Wm= Creates tables with rows sorted in descending order Identifies two characters to be used instead of zero where a cell value is zero or rounds to zero Request a table-level statistic. Names the weighted matrix to be used

Examples: a;decp=1;wm=0;op=12;nopc;dsp;indent=0;nzrow;nzcol; +notype;flush;pagwid=200;paglen=59;spechar=-*; +side=30 You can switch off some of the options by adding no preceding the word Note: All the above mentioned options works on a/sectbeg/flt/tab Statements Does not cover completely. Refer to manual for complete list of options
9

Table Control Statements

Cross tabulating axes

Table control statements name the questions to be cross-tabulated against each other to create tables
Tables are requested by defining the axes to be tabulated on tab statements.
FORMAT: tab axis_name1 axis_name2;options In the above format, axis_name1 becomes the row/ side axis and axis_name2 becomes the column/ breakdown axis in the table

If required, tt statements may be placed after a tab statement. These titles will be printed in addition to the axis titles.

11

Cross tabulating axes

3 dimensional tables may be specified by placing a 3rd axis name after the tab keyword. This axis will act as a page filter. A table of the last 2 axes will be produced for each element of the 1st axis, and each table will be filtered by that element.
tab region age class will produce a table of age by class for each element of region. Each table will be filtered by the relevant element of region.

Be careful when using this future as it can generate large number of tables.

12

Other table control statements


sid
wm=. Defines a table to be printed at the side of the table specified on the previous tab statement. Row axis named with sid should create the same number of rows as the row axis defined on the tab statement. Max 40 sid statements in a tab. Example: tab rows cols;c=c2131/5 sid rows1 cols1;c=c2541/9

sid axis1 axis2; [options]


axis1 and axis2 are axis names; options are any of c=, inc= and

13

More on tab control statements


und und axis1 axis2; [options]
Defines a table to be printed underneath the table specified on the previous tab statement. The column axis defined with und should create the same number of columns as the column axis defined on the tab statement.

Example:

tab rows cols;inc=c(45,48)


und rows2 cols2;inc=c(49,52)

add Specifies a table to be added or combined with the table defined on the previous tab statement. Example: tab ax1 ax2 add ax5 ax6

div Defines the denominator of a table to be produced by dividing the table specified on the previous tab statement by that on the div line.
Example: tab ax07 bk01 div ax08 bk02
14

Axes Control Statements

Defining Axes
Axes are the building blocks of a Quantum program
Broadly speaking, an axis is Quantums way of defining questions from the questionnaire

Each axis consists of statements which establish the conditions and text for the rows and columns of a table.
Axes are cross-tabulated by the tab statement to form tables Axes may be used to create the rows of a table or the columns of a table Every axis must have a name that is unique within your Quantum program. Axes usually contain a title for the question and the answers given to that question. The answers are usually called elements

16

Specifying the name of an axis


Statement:
Format:

l defines start of an axis


l axis_name;options

Where: axis_name is the name of the axis Rules for axis names: May be up to 7 characters long May consist of letters, numbers and the _ character Must start with a letter Must be unique in the program

17

Specifying the name of an axis


Examples
l q1 l age All statements following the l statement are part of the axis, until another l statement occurs. There are many ways of specifying axis elements in Quantum. All may be used within a single axis if required By default an axis is limited to 500 elements. Facilities exist for increasing this limit.

18

Specifying Table titles in the Axis


Each axis usually contains a title describing the question
The title prints at the top of the table when the axis is tabbed down the side of the table

Tables titles are defined on tt statements


tt statements may be left or right justified or centralized
ttl ttc ttr left justified centralized right justified

More than one tt statement may be used in each axis

19

Specifying Table titles in the Axis


Examples:

l q3; ttlQ.3: Likes of Product ttlBase: All respondents

l q15; ttlQ.15: Opinion of performance ttl ttlBase: All answering


20

Defining Individual Elements


The statements are nxx statements, where xx is a 2-digit number
Each n statement defines one element The n10 statement defines a base element

21

Text and conditional elements


The n01 statement defines a single axis element
Elements contain text and conditions which define the characteristics a respondent must have to be included in the element.

General format of a condition


c=logical expression c=cnp is true if column n contains code p , false if it does not Example: n01Female; c=c1251

n01Ford Escort car; c=c(121,123)=101

22

Text and conditional elements


c=- produces a count of all respondents eligible for inclusion in the axis who have not been included in any element other than the base so far
c=-n counts respondents eligible for inclusion in the axis but not counted in the previous n elements c=+ counts respondents already included in one of the previous elements in the axis c=+n counts respondents already included in the previous n elements

23

Text only elements


Elements create nothing but text. No cells containing counts or values are created from these elements.
n03 ---> Creates text-only element

n23 ---> Creates a subheading


n33 ---> Continue long element texts If you would like subheadings to be underlined, place one of the options unl1, unl2 or unl3 on the n23. Unl1 underlines the complete text, unl2 underlines everything except blank strings and unl3 underlines nonblanks only.

24

More on elements
Non-printing elements
It is sometimes necessary to create elements that will not be printed The n11 statement is a non-printing n10 (Base) statement. This is useful for re-basing figures part way through an axis, without printing the new base. The n15 statement is a non-printing n01 statement. Arithmetic elements Elements contain arithmetic values rather than counts. For example, number of times a product was bought rather than the number of people who bought it.

25

More on elements
Statistical elements
These elements contain totals, subtotals or statistical functions such as means and standard deviations.

n statements for Arithmetic/ Statistical elements


n07 Defines an element which is the average of all preceding elements since the last n07 or the beginning of the table. The default for dec=0 n12 Mean values. The default for dec=1 n13 Sum of factors. The default for dec=1 n17 Standard Deviation. The default for dec=2

n19 Standard Error of the mean. The default for dec=2

26

More on elements
Statistical elements
n20 Sample Variance of the mean. The default for dec=2 n30 Medians. The default for dec=0 n04 Specifies an element containing sum totals of all n01, col and val statements in the axis n05 Calculates sub-totals starting from the previous n05, base row or the start of the table, whichever is the most recent

Note: Quantum can not compute Mode of the distribution

27

More on elements
Statistical elements
n20 Sample Variance of the mean. The default for dec=2 n30 Medians. The default for dec=0 n04 Specifies an element containing sum totals of all n01, col and val statements in the axis n05 Calculates sub-totals starting from the previous n05, base row or the start of the table, whichever is the most recent

Note: Quantum can not compute Mode of the distribution

28

Miscellaneous n statements
n00 Format: n00 [; c=condition]
Defines a global filter for an axis which is used in addition to those applied locally to individual elements

n09 Format: n09 [text][; options]


Overrides the automatic page turnover facility by defining the place at which a table should be split if it is too large to fit on the page.
n25 Specifies a filter (c=) and an increment variable (inc=) which are to be used in the calculations performed by subsequent statistical n statements. Example: n25;inc=c(14,15);c=(c(14,15).gt.0) n12 Average excluding zero (helpful in calculating average when the actual values of the variable is entered)

29

More on Axes

The col statement


To define a list of elements with codes all in the same column, we use col
col n;[opts];elm1 [=p1];[%kwd];[;elm2 [=p2][elmx=rej], where

is a column number

opts: are keywords defining header and subheader texts and type of base required elm1 to elm2 : are the element texts p1 to pn: are the codes representing each element kwd: is a list of keywords preceded by percent signs

elmx=rej

is an element for anyone not counted since the last base

31

Col statement cont


options may be any of:
base defines the base element against which any percentages will be calculated. Base=text gives base text printed hd=text Specifies the row heading when the axis is used as a row axis and the overall column heading when the axis is used as a column axis without g statements.

tx=textDefines text only element when the axis is used as row axis. Any number of text-only elements may be defined anywhere on the col statement
Examples: 1. col 109; base;single;married;Divorced;Widowed 2. col 121;base;inner London=1;Outer London=2;England

+Outside London=3;Dk/Cs=rej32

Val statement
To define elements whose condition is that a variable contains a specific value, type:
val var;[opts];op;val1;[kwd];val2;[kwd];valn;[kwd];[text=rej] where var is a data, integer, real or real data variable

opts define heading, subheading and type of base op val1 to valn defines the type of numbers in the statement are ranges or single positive numbers

kwd is a list of option keywords separated by semicolons text=rej base op may be one of: i inclusive ranges (maximum value is a part of range) is an element for anyone not counted since the last

exclusive ranges (maximum value is not part of range) 33

Val statement cont

If the values on the val statement are just numbers which are incremented by 1 for each element, they may be abbreviated using the notation:
val c(m,n);base;=;start:end

The operators =, I and R may be combined in one val statement

Examples:

val c(215,218); base; i ; 0-3000; 3001-4000; 4001+ val c(110,111); base; hd=No.of People in the Household;=;1:9 val t5;=;type1=572; type2=835; r ; type3=400-500; +DK/NA=missing_ val c(110,111);base;hd=Size of Household;=;1 Person;2 People; + i ;3-4 People;5-6 People;7-8 People;9 or more People

34

Example of an axis using val statement

35

The fld statement


To

define elements whose condition is that a field contains a specific numeric code, use
fld col.specs;[opts]; elm1 [=code[,code]][;%kwd];elm2[=code];[elmx=rej]

where col.specs opts elm1 to elm2 code1 to code2 kwd elmx=rej


are the fields containing the data are define heading text and type of base are the element texts are the codes representing each element

is a list of keywords preceded by percent signs is an element for anyone not counted since the last base

36

fld statement contd


The fields containing the data may be defined as: (c(a1,b1), c(a2,b2),)
where c(a1,b1) is the first field to be read, c(a2,b2) is the second field to read, and so on;

(ca1,ca2) :n
where ca1 and ca2 are the start columns of the fields to be read, and n is the field width

ca1,ca2 :n
where ca1 is the start of the first field in a sequential range of fields, ca2 is the start of the last field in that range, and n is the field width. Non-sequential groups of ranges may be listed one after the other as long as each group is separated by a slash

ca1/ca2:n
where ca1 and ca2 are single non-sequential fields, and n is the field width

Note: Up to 20 fields may be specified on one fld statement

37

fld statement contd


Examples:
fld (c(5,6), c(7,8), c(9,10)); base; hd=card owned; ++vw/audi=500-572, 723 fld (c12, c14, c16) :2 This reads c(12,13), c(14,15), c(16,17) fld c12, c16 / c52, c56 :2 This reads c(12,13), c(14,15), c(16,17), c(52,53), c(54,55) and c(56,57) fld c23 / c36 / c71 :2 means c(23,24), c(36,37) and c(71,72). fld (c12, c14, c16) :2;Science Fiction/Fantasy=2, 5; ++Historical=1;Others=3-4

38

Defining banner/ column axis


g and p statements are used to design the way the column heads and the data relating under each column head should appear in the breaks file.
gtext creates column headings. Column texts are entered on the line exactly as they are to be printed on the tables. Blocks of text may be created by grouping g statements together. Examples: g base col1 col2 col3 p p x[|] x[|]x x is any non blank char. | - vertical line Used in conjunction with g statements to determine where each column of figures should be printed in relation to its column heading. Examples: g base col1 col2 col3 p x x x x

39

Example axis defined using g&p

40

More on g&p
In the above example, strictly speaking, there is no need to put element text on n01 statement since the text described on G statements is printed as columns in the table
However, the text showed here serves purpose in two ways will not lead to confusion referring to text described on G statement will get printed in case the break does not fit into the available column width The pagwid should be at least equal to side plus total width of the break

41

About side of the table


By default, side of the table is 24 characters and the maximum allowed limit is 120 characters
Option side=n where n is an integer can be set on the a statement to alter the side of the table If the length of text on count creating element exceeds side=n, Quantum automatically wraps the text. In doing so, the text is broken at a space/ slash/ - type of a character When the text is wrapped up to more than 1 line, the numbers are displayed against the 1st line not the last line When the text is wrapped to more than 1 line, the subsequent lines to the first line can be indented using indent=n command on a statement. For instance indent=1 on a statement indents the text by one character to the right on all subsequent lines to the first line of the text The text on non count creating elements (n03, n23, n33) is not wrapped up when the length of the text exceeds side=n. One has to manually break the text into 2 lines if needed
42

Você também pode gostar