Creating Tables Demo Do File

Creating Tables Demo Do File

by Eric Smith -
Number of replies: 4

Hi everyone,

I have a lab meeting upcoming where I am going to show them how I create publication quality tables for summary statistic and regression models really quickly. It certainly is something to wrap your head around to start but once you figure it out it is going to save you so much time. See attached do file with an example from the nhanes2 dataset to identify risk factors for myocardial infarction. 

As with coding, there are so many different ways to do things. I use the Table1_mc (extension of the Table1 command) to make Table 1 and esttab to make the regression table.

There are still things that I am learning too so any feedback is welcomed! Hope this helps :) 

Summary stats table is at rows 88-102 with optional info at 104-117

Regression model coding begins at row 122 (blurb) and really starts at 140 to 205. I suggest going step by step to see how appearance of the output changes with altering the options 

In reply to Eric Smith

Re: Creating Tables Demo Do File

by Eric Smith -
I forgot to mention is that the output will be in Microsoft Word :)

The time saving comes into play when a coauthor or reviewer tells you to exclude some patients or you get new data and have to manually put everything again X_X
If you get this down you just run the code again and you only have to alter minor details from the table :)
In reply to Eric Smith

Re: Creating Tables Demo Do File

by Mason Lai -
Hi Eric, thanks for the excellent walkthrough, I'm using it to export a regression table for the final assignment. (1) For the final, do you know if it's acceptable to have multiple document outputs that we manually combine for the final submission? (e.g. one .docx output with the intro text and figure, and one .rtf output with the regression table which will be moved into the .docx for final submission). I'm only able to output my regression table as .rtf using your method and using outreg2. (2) Is a way to output the regression table as .docx? Didn't have any success using putdocx. Thanks in advance.
In reply to Mason Lai

Re: Creating Tables Demo Do File

by Eric Smith -

Hi Mason!

I'll leave it to Crystal to answer the question about having it all in one document but I want to say that is the goal. I havent tried using this method to combine multiple figures into one file (which I should practice) but I do know when you click on the rtf file it opens it in a word document. I'm just not sure if the rtf will be compatible with it but give it a shot. 

In reply to Eric Smith

Re: Creating Tables Demo Do File

by Crystal Langlais -
Hi Mason,

If your code outputs to multiple documents, it is perfectly acceptable to manually combined into one for the final submission.

Eric - thanks for posting your examples with detailed comments!! This is another great resource for students and another example of the utility of various user-generated commands. My advice to students would be to find the functions you like best and then keep a stock code (something similar to what Eric just shared) so you can easily tweak the tables for each of your future analyses.