1. Home
  2. PERCENT procedure

PERCENT procedure

Expresses the body of a table as percentages of one of its margins (R.W. Payne).

Options

CLASSIFICATION = factors Factors classifying the margin over which the percentages are to be calculated; if this is not set, the percentages are over the final margin (grand mean or grand total etc.)
METHOD = string token Method to use to calculate the margin if not already present (totals, means, minima, maxima, variances, medians); default tota
HUNDRED = string token Whether to put 100% values into the margin instead of the original values (no, yes); default no

Parameters

OLDTABLE = tables Tables containing the original values
NEWTABLE = tables Tables to store the percentage values; if any of these is unset, the new values replace those in the original table

Description

PERCENT allows you to express the body of a table as percentages of the values in one of its margins. The table is specified using the OLDTABLE parameter. A table to store the new values can be specified using the NEWTABLE parameter, otherwise these replace the values of the original table. The margin is indicated by listing the factors that define it using the CLASSIFICATION option; the default is the final margin (the grand total, or grand mean etc). If the original table has no margins, option METHOD defines how these are to be calculated; the default is to form margins of totals. The values originally in the margin will be left unchanged. If you would prefer these to be replaced by values of 100%, you should set option HUNDRED=yes.

Options: CLASSIFICATION, METHOD, HUNDRED.

Parameters: OLDTABLE, NEWTABLE.

Method

If the OLDTABLE has no margins and contains no missing values, these are formed by the MARGIN directive. Alternatively, if there are missing values, margins other than variances can be formed using TABULATE. CALCULATE is then used to put the required margin into a table classified just by the factors that define the margin. The original table is divided by the marginal table and multiplied by 100 to give the required percentages. If option HUNDRED=no, the same operations are done on a dummy table that originally contains random numbers; for this table, values of 100 should occur only in the margin. Thus by using a logical test in which the values of the dummy table are compared with 100, the marginal values of the original table can be put back into the margin of the final table. The random numbers are generated using a specially written procedure URANDOM in case the Genstat random number generator is already in use in the program that called PERCENT.

See also

Directives: COMBINE, TABLE, TABULATE, MARGIN.

Procedures: MTABULATE, SVSTRATIFIED, SVTABULATE, TABMODE, TABSORT, T%CONTROL.

Commands for: Calculations and manipulation.

Example

CAPTION  'PERCENT example',\
         'Data from the Guide to Genstat, Part 1, Section 4.11.1.';
         STYLE=meta,plain\
VARIATE  [NVALUES=15] Quantity,Charge
FACTOR   [NVALUES=15; LABELS=!T(A,B)] Type
&        [LABELS=!T(London,Manchester,Birmingham,Bristol)] Town
READ     [PRINT=errors] Town,Quantity,Type; FREPRESENTATION=labels
    London 10 A  Manchester   5 B  Birmingham  10 B     Bristol 25 A
Manchester 10 *  Birmingham 100 B      London 200 B  Manchester 25 A
   Bristol 50 A  Birmingham  25 A     Bristol  25 B      London 25 A
    London 50 B  Manchester  25 B      London  50 A  :
&        Charge
10 20 15 15 * 60 80 30 25 15 25 15 40 * * :
CAPTION 'Form tables Totdisp and Payment, as in Section 4.11.1 of the Manual.'
TABULATE [PRINT=totals; CLASSIFICATION=Town,Type] Quantity; TOTALS=Totdisp
&        [CLASSIFICATION=Town] Charge; TOTALS=Payment
PERCENT  Payment; NEWTABLE=%payment
CAPTION  !T('The amount to be paid on behalf of each each town is expressed',\
         'as a percentage of the total of all the payments.')
PRINT    %payment; FIELDWIDTH=8; DECIMALS=2; MNAME=total
PERCENT  [CLASSIFICATION=Town; HUNDRED=yes] Totdisp; NEWTABLE=%disp
CAPTION  !T('The numbers dispatched to each town are expressed',\ 
         'as percentages of the total to that town; the',\ 
         'Town margin contains values of 100%.')
PRINT    %disp; FIELDWIDTH=12; DECIMALS=2; MNAME=total
Updated on June 19, 2019

Was this article helpful?