Announcement

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

  • Descriptive Statistics table in Stata

    Hello, I've been trying to create the table below in Stata. It is possible to create a table like this?? I really appreciate any comments and help
    Thanks in advance
    Last edited by Nicolas Rodriguez; 15 Jan 2018, 17:49.

  • #2
    Hello, I've been trying to create the table below in Stata. It is possible to create a table like this?? I really appreciate any comments and help.
    Thanks in advance
    Click image for larger version

Name:	Captura de pantalla 2018-01-15 a la(s) 21.43.36.png
Views:	1
Size:	26.6 KB
ID:	1425898

    Comment


    • #3
      Hey Nicolas,

      i don't know of any add in that can create a table like you showed.
      I only know of the command outreg which gives you tables of your regression outputs in the most common paper style.

      Comment


      • #4
        Hi Nicolas,

        I don't think it's possible to do it in one command, but it's certainly possible with a bit of playing around.

        The following gets you close, I think:

        Code:
        * Example generated by -dataex-. To install: ssc install dataex
        clear
        input long(subgroup location) int(year value)
        1 1 2002  1000
        1 2 2002   200
        1 1 2005  1200
        1 2 2005   250
        1 1 2010  1400
        1 2 2010   300
        1 1 2015  1600
        1 2 2015   325
        1 1 2020  2000
        1 2 2020   350
        2 1 2002  8000
        2 2 2002  1000
        2 1 2005  8500
        2 2 2005  1200
        2 1 2010  9000
        2 2 2010  1500
        2 1 2015  9500
        2 2 2015  1700
        2 1 2020 10600
        2 2 2020  1850
        end
        label values subgroup subgp_
        label def subgp_ 1 "Regional", modify
        label def subgp_ 2 "Total", modify
        label values location loc_
        label def loc_ 1 "Urban", modify
        label def loc_ 2 "Rural", modify
        
        * Display data on screen
        bys subgroup year (location) : egen sumvalue = sum(value)
        gen pc = 100*value/sumvalue
        table location year, c(sum value sum pc) row by(subgroup) format(%4.1f)
        
        * Export data to Excel
        tabout location year if subgroup==1 [fw=value] using test.xls, c(freq col) f(0 1)
        tabout location year if subgroup==2 [fw=value] using test.xls, c(freq col) f(0 1) append

        Note that I'm using the user-written (SSC) command tabout here, but other similar commands are available, such as outreg as mentioned above by Nils.

        Hope that helps,

        David.






        Comment


        • #5
          Thank you very much David. It worked very good!! I have another question, it is possible to adjust the font to a Times New Roman, add a title with size 14 and a subtitle with size 12, 1 decimal in the percentage number, numbers in thousand. Thank you very much for any advice!!!!

          Comment


          • #6
            Hi Nicolas,

            This is getting beyond my knowledge, I'm afraid, but as far as I'm aware Stata is not set up to handle things like titles, subtitles, fonts etc. This would need to be done in a separate program such as Word, Excel, or a scripting program such as LaTeX. Rather, Stata's purpose is to handle the data itself.

            You can change the global display font for Stata (e.g. type help fonts) but I don't think you can change fonts just for particular output ("on-the-fly").

            As for the decimals: yes, I noticed that too. table doesn't seem to give you the option of having different formats for different columns. I chose "%4.1f" to give one decimal place, but obviously you don't want that for your thousands. Again, this is something best handled by an external program.

            In conclusion, I'd recommend taking your exported Excel-format data ("test.xls" in my example code) and read it into another program to add the aesthetics.

            Others might be able to be of more help -- this isn't really my area of expertise!

            Best wishes,

            David.

            Comment


            • #7
              Thank you ver much David.
              Regards

              Comment

              Working...
              X