Announcement

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

  • A table displaying one numerical and two categorial variables

    Hello,
    I want to create a table that displays earnings for each sex over the years.
    I tried a couple different lines but never got it right, I always get multiple tables instead of one.
    How do you do it so that its in one table?

  • #2
    See the examples between pages 2 and 3 here: https://www.stata.com/manuals/rtable...df#rtableintro

    Comment


    • #3
      You can use the table command inside asdoc, or even better asdocx to do this. See this example
      Code:
      ssc install asdoc
      sysuse nlsw88
      
      * add variable year for this example
      gen year = mod(_n, 10)+2000
      asdocx table year race, c(mean wage) replace
      Click image for larger version

Name:	Capture.PNG
Views:	1
Size:	41.6 KB
ID:	1668574
      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


      • #4
        #1 leaves vague what you want to see for earnings. But many commands will help. To see mean, SD and count:


        Code:
        . sysuse auto, clear
        (1978 automobile data)
        
        . tab foreign rep78 , sum(mpg)

        Comment


        • #5
          Originally posted by Nick Cox View Post
          #1 leaves vague what you want to see for earnings. But many commands will help. To see mean, SD and count:


          Code:
          . sysuse auto, clear
          (1978 automobile data)
          
          . tab foreign rep78 , sum(mpg)
          Thanks that works. Is this table exportable to latex ?

          Comment


          • #6
            I am not a good person to advise on that,

            1. Clearly many people want output as LaTeX or HTML or whatever and several commands offer something of the kind.

            2. That could be really important if, perish the thought, you needed many, many such tables. In some fields there is a ritual of massive appendices with lots of tables. How often does anybody read them?

            #2 is never what I need and #1 is rarely what I need — I am far more likely to produce tables as graphs. I have never tried any of the commands on offer. It seems a lot simpler to write your own mark-up directly.

            Any way, sorry: you need better advice from others.

            Comment


            • #7
              a start on this can be found at
              Code:
              help collect style tex

              Comment


              • #8
                Code:
                table foreign rep78 , stat(mean mpg) stat(sd mpg) stat(freq)
                
                collect style cell result[mean sd], nformat(%4.1f)
                
                collect export test.tex, replace

                Comment


                • #9
                  Originally posted by Bjarte Aagnes View Post
                  Code:
                  table foreign rep78 , stat(mean mpg) stat(sd mpg) stat(freq)
                  
                  collect style cell result[mean sd], nformat(%4.1f)
                  
                  collect export test.tex, replace
                  Thanks it works

                  Comment

                  Working...
                  X