Combines several tables into a single table (D.B. Baird).

### Options

`FACTOR` = factor |
Supplies a factor to index the old tables in the new tables; if unset, an unnamed factor is used |
---|---|

`LEVELS` = variate |
Allows levels to be supplied for the new factor |

`LABELS` = text |
Allows labels to be supplied for the new factor |

### Parameters

`OLDTABLES` = pointers |
Each pointer supplies a set of tables to be combined |
---|---|

`NEWTABLE` = tables |
Table to save each combined set of tables |

`FACVALUES` = variates or texts |
Values for the new factor, to indicate how the old tables should be ordered in the new table, or to allow some old tables to be omitted (available only when either `LEVELS` or `LABELS` are specified); default assumes that old tables are supplied for all the levels, in ascending level order |

`OLDDECIMALS` = scalars, tables or pointers |
Defines numbers of decimal places for the cells in the combined table contributed by each old table |

`NEWDECIMALS` = tables |
Saves tables to define the number of decimal places to use when printing each new table |

### Description

This procedure can be used to produce a new table by combining several tables together. The tables to be combined must be specified, in a pointer, by the `OLDTABLES`

parameter. These must all have the same set of classifying factors, and must either all have margins, or all be without margins.

The new, combined table is saved by the `NEWTABLE`

parameter. This will be classified by the same factors as the original tables, together with an additional factor to index the `OLDTABLES`

. You can use the `FACTOR`

option to specify an identifier for the new factor. If `FACTOR`

is not set, an unnamed factor is used. (So, this will not have an identifier for you refer to.) However, its “extra” attribute is set to `'Tables'`

, so that this label will appear as the title of the new dimension when the table is printed. (For more details, see the description of the `EXTRA`

parameter of the `FACTOR`

directive.)

You can use the `LEVELS`

option to supply a variate of levels for the new factor, and the `LABELS`

option to provide a text of labels. If neither `LEVELS`

or `LABELS`

is set, `TCOMBINE`

uses the identifiers of the tables in the first `OLDTABLES`

pointer as labels, and uses the standard default for the levels (i.e. integers 1, 2 etc). The `OLDTABLES`

pointers must then contain the same number of tables, all in the same order.

Alternatively, provided one of `LEVELS`

or `LABELS`

has been set, you can use the `FACVALUES`

parameter to indicate that an `OLDTABLES`

pointer is either incomplete or in a different order. To use the levels, you set `FACVALUES`

to a variate with a value for each table in the corresponding `OLDTABLES`

pointer, defining the level of the new factor to which it should be allocated. Similarly, you can set `FACVALUES`

to a text use the factor labels. Any level (or label) that is not included in a set of `FACVALUES`

will generate a “slice” of missing values in the new table.

To print the new table effectively, you may find that different number of decimal places are needed for the cells arising from each of the old tables. For example, one of the old tables may have contained means (requiring several decimal places) while another may have contained the numbers observations uised to calculate each of the means (requiring no decimal places). When you print a table using the `PRINT`

directive, you can set the `DECIMALS`

parameter to a table (with identical classifying factors) to define a different number of decimals for every table cell. You can save a suitable table of decimals using the `NEWDECIMALS`

parameter of `TCOMBINE`

. By default `TCOMBINE`

decides on the number of decimals to use for each old table by looking at its decimals attribute. (This can be set by the `DECIMALS`

parameter of the `TABLE`

directive.) Alternatively, you can define your own numbers of decimals using the `OLDDECIMALS`

parameter. Usually you will want to set this to a pointer containing, for each old table, either a scalar (if you want to use the same number of decimals for all its cells) or a table (if you want to specify different ones) However, if you want to use the same decimals for every old table, you can specify a single scalar or a single table instead.

Options: `FACTOR`

, `LEVELS`

, `LABELS`

.

Parameters: `OLDTABLES`

, `NEWTABLE`

, `FACVALUES`

, `OLDDECIMALS`

, `NEWDECIMALS`

.

### See also

Commands for: Calculations and manipulation.

### Example

CAPTION 'Example of how to use procedure TCOMBINE.'; STYLE=major SPLOAD '%GenDir%/Data/Grazing.gsh' CALCULATE Gain_Lwt = Final_Lwt - Initial_Lwt TABULATE [PRINT=*;CLASS=Treatment,Period] Initial_Lwt,Final_Lwt,Gain_Lwt;\ MEANS=MeanI,MeanF,MeanG; SD=SDI,SDF,SDG TEXT [VALUES=Mean,'Standard Deviation'] SLabels TEXT [VALUES=Initial,Final,Gain] VLabels TCOMBINE [FACTOR=Variate; LABELS=VLabels]\ !p(MeanI,MeanF,MeanG),!p(SDI,SDF,SDG); NEWTABLE=Temptab[1,2];\ OLDDECIMALS=1,2; NEWDECIMALS=Tempdec[1,2] TCOMBINE [FACTOR=Statistic; LABELS=SLabels]\ Temptab; NEWTABLE=LwtTable; OLDDECIMALS=Tempdec; NEWDECIMALS=Dec PRINT LwtTable; DECIMALS=Dec