Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • change row and column layout of tabstat

    Dear Stata Users,

    I want to make a table of summary statistics using -tabstat- command, but the results seems to me a bit disappointing. In the table that generated by -tabstat, by(type)- ( column(variables) as default), the variables are listed in column and their summary statistics are listed in row (listed separately for different types). However, in my writing task, I want another layout style: the variables are listed in row and their summary statistics along with the variable of types are listed in column. In the below I will use the auto.dta to give an example. p.s. The user-written command -publish- (from http://web.uni-corvinus.hu/bartus/stata) gives the results that I desire, however I don't choose to resort to it for certain reasons, its table width problem in Word for example.

    Code:
    sysuse auto, clear
    tabstat price weight rep78, by(foreign) format(%9.0f) /*see Table 1*/
    publish open example
    publish sum price weight rep78, by(foreign) contents(mean) total /*see Table 2*/
    publish close
    Click image for larger version

Name:	tabstat.png
Views:	1
Size:	23.9 KB
ID:	1462702

  • #2
    You can get something pretty similar to Table 2 with:

    Code:
    clear*
    sysuse auto
    
    keep foreign price weight mpg rep78
    rename (price weight rep78 mpg) _=
    gen long obs_no = _n
    reshape long _, i(obs_no) j(variable) string
    table variable foreign, col format(%1.0f) c(mean _)

    Comment


    • #3
      Clyde Schechter thank you very much! That is exactly what I desire.

      Comment

      Working...
      X