What is -basetable-

-basetable- is a simpel yet highly efficient tool for interactively building the first table required in most medical/epidemiological papers.

The typical layout of these tables is grouping (categorical) variable as column header and then a set of rows of different variables being compared by each group in the header and in a total.

The tables can off course also be used for survey like analysis.

When the table building is over, the result can be inserted into one or more sheets in a excel workbook. If the labelling of variables and values have been done carefully the table outputs in the excel workbooks will be almost publication ready.

It is tested for Stata version 12 and up although export to Excel only works from Stata version 13 and up.

Syntax

The syntax is: basetable column_variable [summary_variables] [if] [in] [using] [, options]

column_variable

The first argument must be a categorical variable with a value label.

summary_variables

The rest of the arguments are variable names followed by with suboptions inside braces.

Suboptions

Suboptions are:

Header suboptions

Header suboptions are a header text (could be blank) possibly ending with a hashtag (#) for a subcount separated by a comma (,) optionally a separator text for the rest of the columns and optionally a local if condition (The subcount from the hashtag matches the condition)

Categorical variable suboptions

Categorical variables has suboptions:

Continous variable suboptions

Continous variables has a numeric format(eg %6.2f) as first argument and eventually a local report specification (sd, iqr, iqi, ci or pi) separated by a comma.

Options

The options for basetable are:

The example data

We use a modified version of Stata's own hospid2.

-basetable- uses extensively variable labels and value labels in its outputs.

So it is imperative to make sure that all labels are in place.

The commands to build the dataset are:


use low age race ftv smoke using "http://www.stata-press.com/data/r12/hospid2.dta", clear
label define low 0 "Normal" 1 "Low"
label values low low
label define ftv 0 "0 visits" 1 "1 visit" 2 "2 visits" 3 "3 visits" 4 "4 visits" 5 "5 visits" 6 "6 visits"
label values ftv ftv
label define smoke 0 "No" 1 "Yes"
label values smoke smoke

To be able to show the missing report part we add some missing values:


replace low = . in 4/6
replace age = . in 5/8
replace race = . in 3/8

You can get the dataset here

Building reports

The overall example here is to compare the variables age, race, smoke and ftv for different values of the variable low.

In principle there are two sorts of variables: Continous like height, weight, blood preasure etc. And Categorical being grouping variables like sex/gender, age groups, race etc. There are different types of reporting for the two groups.

Continous variables

Continous variables can have up to two arguments separated by comma, no space allowed in the argument string.

First part, the format, is necessary. It is just a standard Stata format that is specified, typically a fixed one like %6.2f saying that the length including dot is 6 and there are 2 decimals shown.

Second part is optional, specifying what is to be reported. It is one of the strings:

The second part if used overrules the overall type of reporting specified by the option continousreport demonstrated below.

Here is all the ways that the continous variable age can be reported:


basetable low age(%6.1f) age(%6.2f,sd) age(%6.0f,iqr) age(%6.0f,iqi) age(%6.1f,ci) age(%6.1f,pi)

----------------------------------------------------------------------------------------------
                                         Normal                Low              Total  P-value
----------------------------------------------------------------------------------------------
n (%)                                127 (68.3)          59 (31.7)        186 (100.0)         
age of mother, mean (sd)             23.7 (5.6)         22.3 (4.5)         23.2 (5.3)     0.10
age of mother, mean (sd)           23.66 (5.55)       22.31 (4.51)       23.22 (5.27)     0.10
age of mother, median (iqr)              23 (9)             22 (6)             23 (7)     0.24
age of mother, median (iqi)         23 (19; 28)        22 (19; 25)        23 (19; 26)     0.24
age of mother, mean (95% ci)  23.7 (22.7; 24.6)  22.3 (21.2; 23.5)  23.2 (22.5; 24.0)     0.10
age of mother, mean (95% pi)  23.7 (12.8; 34.5)  22.3 (13.5; 31.1)  23.2 (12.9; 33.5)     0.10
----------------------------------------------------------------------------------------------

Default reporting can be changed by the option continousreport with one of the arguments sd (default), iqr, iqi, ci or pi.


basetable low race(%6.0f) age(%6.0f), continousreport(iqr)

------------------------------------------------------------------------
                                 Normal        Low        Total  P-value
------------------------------------------------------------------------
n (%)                        127 (68.3)  59 (31.7)  186 (100.0)         
race, median (iqr)                1 (2)      2 (2)        1 (2)     0.06
age of mother, median (iqr)      23 (9)     22 (6)       23 (7)     0.24
------------------------------------------------------------------------

Categorical variables

Categorical variables are grouping variables like sex, race, smoking etc. The typical reporting way for categorical variables is counting numbers and calculating percentages, either raltive to row totals or column totals.

Sometimes only the report of one of the values is needed in the table.

All versions are shown for the variable race below, row percentages (argument: r), column percentages (argument: c), row percentages for the value white of race (argument: white), and a 95% confidence Interval (arguments: white, ci):


basetable low race(r) race(c) race(white) race(white,r) race(white,ci)

------------------------------------------------------------------------------------------
                                     Normal                Low              Total  P-value
------------------------------------------------------------------------------------------
n (%)                            127 (68.3)          59 (31.7)        186 (100.0)         
race, n (%)                                                                               
  white, n (%)                    71 (75.5)          23 (24.5)         94 (100.0)         
  black, n (%)                    14 (56.0)          11 (44.0)         25 (100.0)         
  other, n (%)                    39 (60.9)          25 (39.1)         64 (100.0)     0.06
race, n (%)                                                                               
  white, n (%)                    71 (57.3)          23 (39.0)          94 (51.4)         
  black, n (%)                    14 (11.3)          11 (18.6)          25 (13.7)         
  other, n (%)                    39 (31.5)          25 (42.4)          64 (35.0)     0.06
race (white), n (%)               71 (57.3)          23 (39.0)          94 (51.4)     0.06
race (white), n (%)               71 (75.5)          23 (24.5)         94 (100.0)     0.06
race (white), % (95% ci)  57.3 (48.6; 66.0)  39.0 (26.5; 51.4)  51.4 (44.1; 58.6)     0.06
------------------------------------------------------------------------------------------

In the next 2 subsections a comparison with the -basetable- report is necessary:


basetable low ftv(c)

------------------------------------------------------------------------------------------------------
                                                               Normal        Low        Total  P-value
------------------------------------------------------------------------------------------------------
n (%)                                                      127 (68.3)  59 (31.7)  186 (100.0)         
number of visits to physician during 1st trimester, n (%)                                             
  0 visits, n (%)                                           62 (48.8)  36 (61.0)    98 (52.7)         
  1 visit, n (%)                                            35 (27.6)  11 (18.6)    46 (24.7)         
  2 visits, n (%)                                           23 (18.1)   7 (11.9)    30 (16.1)         
  3 visits, n (%)                                             3 (2.4)    4 (6.8)      7 (3.8)         
  4 visits, n (%)                                             3 (2.4)    1 (1.7)      4 (2.2)         
  6 visits, n (%)                                             1 (0.8)    0 (0.0)      1 (0.5)     0.30
------------------------------------------------------------------------------------------------------

Setting the overall percentage format

The overall percentages format can be changed by the option pctformat with a number format as an argument. Below is the overall percentage format set to be of length 6 and with 3 decimals:


basetable low ftv(c), pctformat(%6.3f)

------------------------------------------------------------------------------------------------------------
                                                                 Normal          Low          Total  P-value
------------------------------------------------------------------------------------------------------------
n (%)                                                      127 (68.280)  59 (31.720)  186 (100.000)         
number of visits to physician during 1st trimester, n (%)                                                   
  0 visits, n (%)                                           62 (48.819)  36 (61.017)    98 (52.688)         
  1 visit, n (%)                                            35 (27.559)  11 (18.644)    46 (24.731)         
  2 visits, n (%)                                           23 (18.110)   7 (11.864)    30 (16.129)         
  3 visits, n (%)                                             3 (2.362)    4 (6.780)      7 (3.763)         
  4 visits, n (%)                                             3 (2.362)    1 (1.695)      4 (2.151)         
  6 visits, n (%)                                             1 (0.787)    0 (0.000)      1 (0.538)     0.30
------------------------------------------------------------------------------------------------------------

Hide small count values

When working eg at places like Denmark Statistics it is important to anomyze individuals by not reporting small counts, eg counts less than 5.

This is handled in -basetable- by optional options hidesmall (hide small values) and small (specifying the limit for what is small, default is 5).

Two examples:


basetable low ftv(c) ftv(r), hidesmall

------------------------------------------------------------------------------------------------------
                                                               Normal        Low        Total  P-value
------------------------------------------------------------------------------------------------------
n (%)                                                      127 (68.3)  59 (31.7)  186 (100.0)         
number of visits to physician during 1st trimester, n (%)                                             
  0 visits, n (%)                                           62 (48.8)  36 (61.0)    98 (52.7)         
  1 visit, n (%)                                            35 (27.6)  11 (18.6)    46 (24.7)         
  2 visits, n (%)                                           23 (18.1)   7 (11.9)    30 (16.1)         
  3 visits, n (%)                                             < 5 (.)    < 5 (.)     < 10 (.)         
  4 visits, n (%)                                             < 5 (.)    < 5 (.)     < 10 (.)         
  6 visits, n (%)                                             < 5 (.)    0 (0.0)      < 5 (.)     0.30
number of visits to physician during 1st trimester, n (%)                                             
  0 visits, n (%)                                           62 (63.3)  36 (36.7)   98 (100.0)         
  1 visit, n (%)                                            35 (76.1)  11 (23.9)   46 (100.0)         
  2 visits, n (%)                                           23 (76.7)   7 (23.3)   30 (100.0)         
  3 visits, n (%)                                             < 5 (.)    < 5 (.)     < 10 (.)         
  4 visits, n (%)                                             < 5 (.)    < 5 (.)     < 10 (.)         
  6 visits, n (%)                                             < 5 (.)    0 (0.0)      < 5 (.)     0.30
------------------------------------------------------------------------------------------------------

basetable low ftv(c) ftv(r), hidesmall small(8)

------------------------------------------------------------------------------------------------------
                                                               Normal        Low        Total  P-value
------------------------------------------------------------------------------------------------------
n (%)                                                      127 (68.3)  59 (31.7)  186 (100.0)         
number of visits to physician during 1st trimester, n (%)                                             
  0 visits, n (%)                                           62 (48.8)  36 (61.0)    98 (52.7)         
  1 visit, n (%)                                            35 (27.6)  11 (18.6)    46 (24.7)         
  2 visits, n (%)                                           23 (18.1)    < 8 (.)     < 31 (.)         
  3 visits, n (%)                                             < 8 (.)    < 8 (.)     < 16 (.)         
  4 visits, n (%)                                             < 8 (.)    < 8 (.)     < 16 (.)         
  6 visits, n (%)                                             < 8 (.)    0 (0.0)      < 8 (.)     0.30
number of visits to physician during 1st trimester, n (%)                                             
  0 visits, n (%)                                           62 (63.3)  36 (36.7)   98 (100.0)         
  1 visit, n (%)                                            35 (76.1)  11 (23.9)   46 (100.0)         
  2 visits, n (%)                                           23 (76.7)    < 8 (.)     < 31 (.)         
  3 visits, n (%)                                             < 8 (.)    < 8 (.)     < 16 (.)         
  4 visits, n (%)                                             < 8 (.)    < 8 (.)     < 16 (.)         
  6 visits, n (%)                                             < 8 (.)    0 (0.0)      < 8 (.)     0.30
------------------------------------------------------------------------------------------------------

Using if and in

It is now possible to use [if] and [in] in connection with basetable:


basetable low [Continous,***] age(%6.0f,iqr) age(%6.0f,iqi) [***, ***] [Categorical] ftv(c) race(c) if smoke == 1 in 100/180

---------------------------------------------------------------------------------------------------------
                                                                Normal          Low        Total  P-value
---------------------------------------------------------------------------------------------------------
n (%)                                                          2 (6.9)    27 (93.1)   29 (100.0)         
Continous                                                          ***          ***          ***      ***
age of mother, median (iqr)                                     30 (3)       22 (7)       23 (8)     0.09
age of mother, median (iqi)                                30 (28; 31)  22 (19; 26)  23 (20; 28)     0.09
***                                                                ***          ***          ***      ***
Categorical                                                                                              
number of visits to physician during 1st trimester, n (%)                                                
  0 visits, n (%)                                              0 (0.0)    19 (70.4)    19 (65.5)         
  1 visit, n (%)                                               0 (0.0)     4 (14.8)     4 (13.8)         
  2 visits, n (%)                                             1 (50.0)      1 (3.7)      2 (6.9)         
  3 visits, n (%)                                              0 (0.0)     3 (11.1)     3 (10.3)         
  6 visits, n (%)                                             1 (50.0)      0 (0.0)      1 (3.4)     0.00
race, n (%)                                                                                              
  white, n (%)                                                1 (50.0)    16 (59.3)    17 (58.6)         
  black, n (%)                                                 0 (0.0)     6 (22.2)     6 (20.7)         
  other, n (%)                                                1 (50.0)     5 (18.5)     6 (20.7)     0.51
---------------------------------------------------------------------------------------------------------

Separating large tables into blocks

Sometimes the variables can be grouped, eg into Continous and Categorical variables.

It is possible to add headers in the variable list like [headedtext, separator] - headertext in the label column and separator shown in the rest of the columns. In older versions it was ordinary brackets instead of squared ones that were used for headers.

Note that commas are not allowed in headedtext.

Below is added [Continous, ***] and [Categorical], default separator is blank:


basetable low [Continous, ***] age(%6.0f,iqr) age(%6.0f,iqi) [***,***] [Categorical] ftv(c) race(c) smoke(Yes)

---------------------------------------------------------------------------------------------------------
                                                                Normal          Low        Total  P-value
---------------------------------------------------------------------------------------------------------
n (%)                                                       127 (68.3)    59 (31.7)  186 (100.0)         
Continous                                                          ***          ***          ***      ***
age of mother, median (iqr)                                     23 (9)       22 (6)       23 (7)     0.24
age of mother, median (iqi)                                23 (19; 28)  22 (19; 25)  23 (19; 26)     0.24
***                                                                ***          ***          ***      ***
Categorical                                                                                              
number of visits to physician during 1st trimester, n (%)                                                
  0 visits, n (%)                                            62 (48.8)    36 (61.0)    98 (52.7)         
  1 visit, n (%)                                             35 (27.6)    11 (18.6)    46 (24.7)         
  2 visits, n (%)                                            23 (18.1)     7 (11.9)    30 (16.1)         
  3 visits, n (%)                                              3 (2.4)      4 (6.8)      7 (3.8)         
  4 visits, n (%)                                              3 (2.4)      1 (1.7)      4 (2.2)         
  6 visits, n (%)                                              1 (0.8)      0 (0.0)      1 (0.5)     0.30
race, n (%)                                                                                              
  white, n (%)                                               71 (57.3)    23 (39.0)    94 (51.4)         
  black, n (%)                                               14 (11.3)    11 (18.6)    25 (13.7)         
  other, n (%)                                               39 (31.5)    25 (42.4)    64 (35.0)     0.06
smoked during pregnancy (Yes), n (%)                         41 (32.3)    30 (50.8)    71 (38.2)     0.02
---------------------------------------------------------------------------------------------------------

Actually it is also possible to add an local if statement to the header like eg [Race White, if race == 1] limiting the calculations following to that condition as well as the global.

A header with no conditions resets the local condition back to the global condition.

It is demonstrated below:


basetable low [Race All] age(%6.0f,iqi) [Race White #, if race == 1] ///
        age(%6.0f,iqi) [Race Black #, if race == 2] age(%6.0f,iqi) ///
        [Race Other #, if race == 3] age(%6.0f,iqi) [Race All] age(%6.0f,iqi)

---------------------------------------------------------------------------
                                  Normal          Low        Total  P-value
---------------------------------------------------------------------------
n (%)                         127 (68.3)    59 (31.7)  186 (100.0)         
Race All                                                                   
age of mother, median (iqi)  23 (19; 28)  22 (19; 25)  23 (19; 26)     0.24
Race White                                                                 
n (%)                          71 (75.5)    23 (24.5)   94 (100.0)         
age of mother, median (iqi)  24 (20; 29)  22 (19; 26)  24 (20; 29)     0.23
Race Black                                                                 
n (%)                          14 (56.0)    11 (44.0)   25 (100.0)         
age of mother, median (iqi)  20 (17; 23)  21 (18; 24)  20 (17; 24)     0.26
Race Other                                                                 
n (%)                          39 (60.9)    25 (39.1)   64 (100.0)         
age of mother, median (iqi)  22 (19; 28)  23 (20; 25)  23 (19; 25)     0.62
Race All                                                                   
age of mother, median (iqi)  23 (19; 28)  22 (19; 25)  23 (19; 26)     0.24
---------------------------------------------------------------------------

Note that adding a # to the header text adds a count a percentage for the specified condition.

The tables with local if statements leaves "empty" when needed:


basetable low age(%6.2f, iqi) race(c) [Only low birth of non-blacks #, if low == 1 & race != 2] age(%6.2f, iqi) race(c)

at least two populations are required
--------------------------------------------------------------------------------------------------------
                                             Normal                   Low                 Total  P-value
--------------------------------------------------------------------------------------------------------
n (%)                                    127 (68.3)             59 (31.7)           186 (100.0)         
age of mother, median (iqi)    23.00 (19.00; 28.00)  22.00 (19.00; 25.00)  23.00 (19.00; 26.00)     0.24
race, n (%)                                                                                             
  white, n (%)                            71 (57.3)             23 (39.0)             94 (51.4)         
  black, n (%)                            14 (11.3)             11 (18.6)             25 (13.7)         
  other, n (%)                            39 (31.5)             25 (42.4)             64 (35.0)     0.06
Only low birth of non-blacks                                                                            
n (%)                                         . (.)            48 (100.0)            48 (100.0)         
age of mother, median (iqi)                . (.; .)  22.50 (19.50; 25.00)  22.50 (19.50; 25.00)         
race, n (%)                                                                                             
  white, n (%)                                . (.)             23 (47.9)             23 (47.9)         
  other, n (%)                                . (.)             25 (52.1)             25 (52.1)        .
--------------------------------------------------------------------------------------------------------

Adding missing values report

Adding the option missing (or m) adds an extra column with a missing report:


basetable low [Continous,***] age(%6.0f,iqr) age(%6.0f,iqi) [Categorical] ftv(c) race(c) smoke(Yes), missing

-----------------------------------------------------------------------------------------------------------------------------
                                                                Normal          Low        Total  P-value  Missings / N (Pct)
-----------------------------------------------------------------------------------------------------------------------------
n (%)                                                       127 (68.3)    59 (31.7)  186 (100.0)               3 / 189 (1.59)
Continous                                                          ***          ***          ***      ***                 ***
age of mother, median (iqr)                                     23 (9)       22 (6)       23 (7)     0.24      4 / 189 (2.12)
age of mother, median (iqi)                                23 (19; 28)  22 (19; 25)  23 (19; 26)     0.24      4 / 189 (2.12)
Categorical                                                                                                                  
number of visits to physician during 1st trimester, n (%)                                                                    
  0 visits, n (%)                                            62 (48.8)    36 (61.0)    98 (52.7)                             
  1 visit, n (%)                                             35 (27.6)    11 (18.6)    46 (24.7)                             
  2 visits, n (%)                                            23 (18.1)     7 (11.9)    30 (16.1)                             
  3 visits, n (%)                                              3 (2.4)      4 (6.8)      7 (3.8)                             
  4 visits, n (%)                                              3 (2.4)      1 (1.7)      4 (2.2)                             
  6 visits, n (%)                                              1 (0.8)      0 (0.0)      1 (0.5)     0.30      0 / 189 (0.00)
race, n (%)                                                                                                                  
  white, n (%)                                               71 (57.3)    23 (39.0)    94 (51.4)                             
  black, n (%)                                               14 (11.3)    11 (18.6)    25 (13.7)                             
  other, n (%)                                               39 (31.5)    25 (42.4)    64 (35.0)     0.06      6 / 189 (3.17)
smoked during pregnancy (Yes), n (%)                         41 (32.3)    30 (50.8)    71 (38.2)     0.02      0 / 189 (0.00)
-----------------------------------------------------------------------------------------------------------------------------

Sending the output for excel workbooks

The table can at any time be send to an Excel workbook with the option and toxl the arguments: path_and_name_of_the_excelfile, sheetname, rownumber, columnnumber, replace. The last 3 arguments are optional, but rownumber and columnnumber must be there both or not at all.

If the workbook exists the sheet is added if the sheet doesn't already exists. To overwrite a existing worksheet use the argument replace.

Below is shown how to add 2 tables in 2 sheets of a workbook and then overwrite the first table:


capture rm "tables.xls" // To remove outfile if it exists
basetable low age(%6.2f) race(c) smoke(Yes), toxl(tables.xls, Tabel 1)

---------------------------------------------------------------------------------------
                                            Normal           Low         Total  P-value
---------------------------------------------------------------------------------------
n (%)                                   127 (68.3)     59 (31.7)   186 (100.0)         
age of mother, mean (sd)              23.66 (5.55)  22.31 (4.51)  23.22 (5.27)     0.10
race, n (%)                                                                            
  white, n (%)                           71 (57.3)     23 (39.0)     94 (51.4)         
  black, n (%)                           14 (11.3)     11 (18.6)     25 (13.7)         
  other, n (%)                           39 (31.5)     25 (42.4)     64 (35.0)     0.06
smoked during pregnancy (Yes), n (%)     41 (32.3)     30 (50.8)     71 (38.2)     0.02
---------------------------------------------------------------------------------------
Table send to Excel succesfully...

basetable low age(%6.2f,iqi) race(r) smoke(Yes), toxl(tables.xls, Tabel 2)

---------------------------------------------------------------------------------------------------------------
                                                    Normal                   Low                 Total  P-value
---------------------------------------------------------------------------------------------------------------
n (%)                                           127 (68.3)             59 (31.7)           186 (100.0)         
age of mother, median (iqi)           23.00 (19.00; 28.00)  22.00 (19.00; 25.00)  23.00 (19.00; 26.00)     0.24
race, n (%)                                                                                                    
  white, n (%)                                   71 (75.5)             23 (24.5)            94 (100.0)         
  black, n (%)                                   14 (56.0)             11 (44.0)            25 (100.0)         
  other, n (%)                                   39 (60.9)             25 (39.1)            64 (100.0)     0.06
smoked during pregnancy (Yes), n (%)             41 (32.3)             30 (50.8)             71 (38.2)     0.02
---------------------------------------------------------------------------------------------------------------
Table send to Excel succesfully...

basetable low age(%6.2f,ci) race(r) smoke(Yes), toxl(tables.xls, Tabel 1, replace)

---------------------------------------------------------------------------------------------------------------
                                                    Normal                   Low                 Total  P-value
---------------------------------------------------------------------------------------------------------------
n (%)                                           127 (68.3)             59 (31.7)           186 (100.0)         
age of mother, mean (95% ci)          23.66 (22.68; 24.63)  22.31 (21.15; 23.46)  23.22 (22.46; 23.98)     0.10
race, n (%)                                                                                                    
  white, n (%)                                   71 (75.5)             23 (24.5)            94 (100.0)         
  black, n (%)                                   14 (56.0)             11 (44.0)            25 (100.0)         
  other, n (%)                                   39 (60.9)             25 (39.1)            64 (100.0)     0.06
smoked during pregnancy (Yes), n (%)             41 (32.3)             30 (50.8)             71 (38.2)     0.02
---------------------------------------------------------------------------------------------------------------
Table send to Excel succesfully...

You can see result here

Just answer Yes if Excel promts you at opening the file. It is a Stata/Excel bug.

Handling errors

Errors should be presented where they are seen. In this case it means that errors are presented as lines int the table.

For example if there are to few observations:


basetable low age(%6.1f) if ftv == 6

--------------------------------------------------------------
                             Normal    Low      Total  P-value
--------------------------------------------------------------
n (%)                     1 (100.0)  . (.)  1 (100.0)         
age of mother, mean (sd)   28.0 (.)  . (.)   28.0 (.)         
--------------------------------------------------------------

If a non existing variable is used for columns:


capture noisily basetable slow

      basetable_parser():  3498  First argument: Argument |slow| must be variable name [23]
                 :     -  function returned error

If a string variable is used for columns:


generate str_low = string(low)
capture noisily basetable str_low

      basetable_parser():  3498  First argument: Variable |str_low| must be numerical [23]
                 :     -  function returned error

If a variable with no value labels is used for columns:


generate low_no_lbl = low

(3 missing values generated)

capture noisily basetable low_no_lbl

      basetable_parser():  3498  First argument: Variable |low_no_lbl| must have a variable label [23]
                 :     -  function returned error

basetable low low_no_lbl(r)

---------------------------------------------------------------------------------------------
                                                      Normal        Low        Total  P-value
---------------------------------------------------------------------------------------------
n (%)                                             127 (68.3)  59 (31.7)  186 (100.0)         
Variable |low_no_lbl| must have a variable label     ERROR!!    ERROR!!      ERROR!!  ERROR!!
Argument |(r)| must be variable name                 ERROR!!    ERROR!!      ERROR!!  ERROR!!
---------------------------------------------------------------------------------------------

generate age_no_lbl = age

(4 missing values generated)

basetable low age_no_lbl(%6.2f)

---------------------------------------------------------------------------------------------
                                                      Normal        Low        Total  P-value
---------------------------------------------------------------------------------------------
n (%)                                             127 (68.3)  59 (31.7)  186 (100.0)         
Variable |age_no_lbl| must have a variable label     ERROR!!    ERROR!!      ERROR!!  ERROR!!
Argument |(%6.2f)| must be variable name             ERROR!!    ERROR!!      ERROR!!  ERROR!!
---------------------------------------------------------------------------------------------

If wrong arguments are set for the summary variables:


basetable low age(%6.2d,iqi) age(%6.2f,iqir) race(elf)

---------------------------------------------------------------------------------------------
                                                      Normal        Low        Total  P-value
---------------------------------------------------------------------------------------------
n (%)                                             127 (68.3)  59 (31.7)  186 (100.0)         
Variable |age| must have a value label assigned!     ERROR!!    ERROR!!      ERROR!!  ERROR!!
Argument |(%6.2d,iqi)| must be variable name         ERROR!!    ERROR!!      ERROR!!  ERROR!!
race (elf), n (%)                                      0 (.)      0 (.)        0 (.)        .
---------------------------------------------------------------------------------------------

If values cannot be calculated a dot (missing) is set in its place (sd is missing for age when birthweight is low):


basetable low age(%6.1f) if ftv == 4

-------------------------------------------------------------------
                              Normal       Low       Total  P-value
-------------------------------------------------------------------
n (%)                       3 (75.0)  1 (25.0)   4 (100.0)         
age of mother, mean (sd)  26.7 (9.2)  21.0 (.)  25.3 (8.1)     0.65
-------------------------------------------------------------------

The do file for this document

Last update: 2017-03-31