Home

Products

  • Overview of Stata
  • Why buy Stata?
  • Stata Journal
  • Stat/Transfer
  • Prices

    Australia

  • New purchases
  • Upgrade
  • Bookshop
  • GradPlan


  • New Zealand

  • New purchases
  • Upgrade
  • Bookshop
  • GradPlan
  • Support

  • Starting Stata
  • Stata tips - General
  • Stata tips - Graphs
  • Stata tips - Tables
  • Technical
  • Stata Courses & Training


  • Order form

    Contact us

    Stata Tables

    Below are examples of Stata table commands.

    Stata user written table commands that have there own web page can be found at:
    http://repec.org/bocode/e/estout/

    http://www.ianwatson.com.au/stata.html




    
    
    
    
    Table
    Output: out (for use in a Excel document) Table where the output can be loaded on a spreadsheet. ie After running the code below open the file (table1.out) into a spreadsheet. Requires: ctable download ctable Click here

    Download ctable help

    To run the example: copy the following into a do file and run use http://www.stata-press.com/data/r11/nlswork.dta, clear set more off collapse (sum) hours (mean) worked=hours (mean) union_member=union ,by(year) fast //label the variables with the label required for the table label var hours "Total hours worked by participants" label var year "The Year" label var worked "Mean hours worked" label var union_member "Percentage Union Membership" ctable, per(union_member) saving(c:\table1) replace f3(worked) /// f2( union_member) width(15) list, sep(0) noheader
     
    
    
    
    
    
    Table
    Output: rtf (for use in a Word document) Twoway table where the output can be loaded on a Word document. ie After running the code below open the file (mydoc3.rtf) into Word. Requires: rtfutil To download rtfutil type the following on the Stata command line: ssc install rtfutil
    To run the example: copy the following into a do file and run use http://www.stata-press.com/data/r11/nlswork.dta, clear collapse (sum) hours (mean) worked=hours (mean) union_member=union ,by(year) fast format worked %8.2f format union_member %8.2f sdecode hours, replace prefix("\qr{") suffix("}") sdecode worked, replace prefix("\qr{") suffix("}") sdecode union_member, replace prefix("\qr{") suffix("}") sdecode year, replace prefix("\qr{") suffix("}") order year hours worked union_member tempname handle3 rtfopen `handle3' using "mydoc3.rtf", template(fnmono1) replace capture noisily { file write `handle3' /// "{\pard\qr{\b Table of hours and union membership years 1968-1988}\par}" _n rtfrstyle year hours worked union_member, tdadd("\trqr") /// cdadd("\clbrdrt\brdrw20\brdrtriple\clbrdrb\brdrw20\brdrtriple") /// cwidths(2160 1440 1440 1440) local(B) rtfrstyle year hours worked union_member, tdadd("\trqr") /// cwidths(2160 1440 1440 1440) local(b d e ) listtab year hours worked union_member, handle(`handle3') /// begin("`b'") delim("`d'") end("`e'") /// head("`B'\ql{\i The Year}`d'\qr{\i Mean hours worked }`d'" /// "\qr{\i Total hours Worked by Participants}`d'" /// "\qr{\i Percentage Union Membership }`e'") } rtfclose `handle3'
     
    


    
    
    
    
    Twoway Table with options
    There are many options including row/column/cell percentages, row/column total etc. Output: Stata results Window Requires: tab2way To download tab2way type the following on the Stata command line: ssc install tab2way
    To run the example: copy the following into a do file and run sysuse auto, clear egen price_cat = cut(price), group(4) tab2way price_cat rep78, allpct colp format(%5.3f) allt usemiss
     
    


    More tables to be added from time to time