Announcement

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

  • Tabout tab with freq and percent

    Hello everybody,

    I need to have excel output of tab commands, but with percentage and frequency.

    Lets take an example with this base and 2 categorical variables:

    HTML Code:
    sysuse voter
    
    tab inc
    
    xtile population = pop, nquantiles(2)

    When I use tabout, to put this in an excel file, i can only get frequencies OR percentages. But…. I need both.


    If i do:

    HTML Code:
    tabout population inc using file.xlsx
    > i loose percentage

    If i do:

    HTML Code:
    tabout population inc using file.xlsx, percent
    > I loose frequency


    Do you have an idea on that ?

    btw since 3 days i cannot open anymore the excel files created by tabout, but i dont think it will be a major problem.


    Thanks you,
    Last edited by Rogerio Paris; 17 Aug 2016, 14:48.

  • #2
    Personally I don't see the difference between the two codes above, the percent option doesn't work because it doesn't know which percentage to display.
    However you could easily have both frequency and percentages with the following line.

    Code:
    tabout population inc using filep.txt, cells(freq col)
    Note that the col option will give you the column percentage, and could be replaced by the row option (or could be both displayed.)

    Concerning the excel files that can't be opened, I'm afraid this is because tabout is made to produce text (.txt) and not .xls.

    Hope this helps.
    Charlie

    Comment


    • #3
      Charlie point exactly to the problem with your code. however, tabout is able to work with MS Excel and to produce xls files but not xlsx files.
      Code:
       tabout population inc using filep.xls, cells(freq col)

      Comment


      • #4
        Hello,
        thank you for your replies, indeed it works with xls and it works with cell(freq col).

        I just have a last concern. Tabout cell(freq row) exports freq and row percentage in a different way han tabulate. it's like two merged charts:

        Click image for larger version

Name:	Capture d’écran 2016-08-18 à 10.58.37.png
Views:	1
Size:	25.0 KB
ID:	1353578


        Apparently, there is no option,in the tabulate command, to put the freq and col in the same column or in the same cell, which would be very useful. If not I will have to arrange all the charts by hand...

        thanks

        Comment


        • #5
          You are right there is no such option. You may find some helpful examples in the PDF manual: http://www.ianwatson.com.au/stata/tabout_tutorial.pdf

          Comment


          • #6
            hi, thanks for the link. I managed to have interesting results now and I'll continue learning about tabout.

            Comment


            • #7
              Hello. Thanks for description of tabout command. Could you also share how to add P-values for characteristics? Beforehand thank you.

              Comment

              Working...
              X