Announcement

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

  • tabout

    I am trying to use tabout in a do file, tabout tgrade q18 if female==0 using t1, sum
    and I get invalid syntax

    I have used this before and it used to work

  • #2
    Welcome to Statalist.

    The uninformative "invalid syntax" message, on examination, was caused by tabout overlooking the syntax error you apparently have, and then as a consequence making a syntax error of its own when calling a subcommand, which then threw the invalid syntax error causing tabout to quit. In my opinion, this is not appropriately robust code.

    I am not a knowledgeable user of tabout, but it appears to me that you need to accompany your sum option with a cells option.
    Code:
    . sysuse auto, clear
    (1978 Automobile Data)
    
    . tabout rep78 foreign using t1, replace
    
    Table output written to: t1
    
            Car type                
    Repair Record 1978      Domestic        Foreign Total
            No.     No.     No.
    1       2.0     0.0     2.0
    2       8.0     0.0     8.0
    3       27.0    3.0     30.0
    4       9.0     9.0     18.0
    5       2.0     9.0     11.0
    Total   48.0    21.0    69.0
    
    . tabout rep78 foreign using t2, replace sum
    invalid syntax
    r(198);
    
    . tabout rep78 foreign using t3, replace sum cells(N mpg)
    
    Table output written to: t3
    
            Car type                
    Repair Record 1978      Domestic        Foreign Total
            N mpg   N mpg   N mpg
    1       2.0     0.0     2.0
    2       8.0     0.0     8.0
    3       27.0    3.0     30.0
    4       9.0     9.0     18.0
    5       2.0     9.0     11.0
    Total   48.0    21.0    69.0

    Comment


    • #3
      You can also use asdoc for tabulation of variables. asdoc can be downloaded from SSC. See the example used by William Lisoski
      Code:
      ssc install asdoc
      sysuse auto
      asdoc tab rep78 foreign
      Click image for larger version

Name:	Capture.JPG
Views:	1
Size:	58.2 KB
ID:	1488484


      https://fintechprofessor.com/2018/01/31/asdoc/
      To find out more on asdoc, read this short blog entry

      Regards
      --------------------------------------------------
      Attaullah Shah, PhD.
      Professor of Finance, Institute of Management Sciences Peshawar, Pakistan
      FinTechProfessor.com
      https://asdocx.com
      Check out my asdoc program, which sends outputs to MS Word.
      For more flexibility, consider using asdocx which can send Stata outputs to MS Word, Excel, LaTeX, or HTML.

      Comment

      Working...
      X