The STATA "table1" Command

The STATA "table1" Command

by Simon -
Number of replies: 5

Hi all,

Has anyone seen the Table1 command? It builds a customized table 1 for you.

To install into your version of STATA enter

"ssc install table1"  in the command line

then search 'table1' in STATA commands for a description of how it works.

I haven't tried it yet so use at your own risk, but it looks like a nice short-cut perhaps?

 

In reply to Simon

Re: The STATA "table1" Command

by Simon -

Here is a description...

 table1 generates a "table 1" of characteristics for a manuscript. Such a table generally includes a collection of baseline characteristics which may be either continuous or     categorical. The observations are often grouped, with a "p-value" column on the right comparing the characteristics between groups.

    The vars option is required and contains a list of the variable/s to be included as rows in the table. Each variable must also have a type specified (contn, conts, cat, cate, bin or     bine - see above). If the observations are grouped using by(), a significance test is performed to compare each characteristic between groups. contn variables are compared using     ANOVA, conts variables are compared using the Wilcoxon rank-sum (2 groups) or Kruskal-Wallis (>2 groups) test, cat and bin variables are compared using Pearson's chi-squared and cate     and bine variables are compared using Fisher's exact test. Specifying the test option adds a column to the table describing the test used.

    The display format of each variable in the table depends on the variable type. For continuous variables the default display format is the same as that variable's current display     format. You can change the table's default display format for continuous variables using the format() option.  For categorical variables the default is to display the proportion using     either 0 or 1 decimal place depending on the total frequency. After each variable's type you may optionally specify a display format to override the table's default.

    The list of variables is delimited using a backslash (\).

    The resulting table may be saved to an Excel file using the saving() option. The file_spec contains the file path and optionally ", replace" to replace any existing file.  You can     also specify the sheet of the Excel file using ", sheet(sheetname)".

    The resulting table can be kept in memory, replacing the original dataset, using the clear option.

 

In reply to Simon

Re: The STATA "table1" Command

by Mark Pletcher -

Neat!  I'll give it a try.

In reply to Mark Pletcher

Re: The STATA "table1" Command

by Simon -

Works really well and exports straight to Excel as a whole table for further editing to a finished product.

Overall faster than doing a chi2 etc row by row and pasting into a dummy table in Excel.

I ran it twice, and identified which rows needed a Fishers exact test vs a Chi2 (this requires entering 'cate' rather than 'cat' after the variable in the command)

It can do a t-test or even non-parametric tests as needed, depending on the variables.

Simon 

 

In reply to Simon

Re: The STATA "table1" Command

by Michael Wilson -

This is a great command. Has anyone figured out how to include the title and footnote options? Also, I am able to relabel my rows but not my columns. Any ideas on this?

Thanks,
Michael

In reply to Michael Wilson

Re: The STATA "table1" Command

by Michael Peters -

I don't know how to do it using the table 1 command.  But generally if you label your variables in stata using the label command, the labels will appear in functions.  Alternatively, you can use the table1 command and then save as an excel file.  Then it would be pretty easy just to type in/change your column labels in excel.

 

MCP