Announcement

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

  • percentage format in tabulate x1 x2, row

    Hi all,

    My problem is very simple but lamentably I can´t find a solution: I am trying to put percentage sign or add parentheses to percentage values in a table 2x2 .

    Regards
    Rodrigo

  • #2
    There are ways to do that in Stata, but can you post an example of the table that you want to modify? Do you use tabulate twoway command? Alternatively, you can try pasting your table on Excel, use Excel's "Text to Columns" under the data tab, and then edit your table to add parentheses and percentage signs.

    Comment


    • #3
      Hi Cyrus,

      Thanks for you reply, I am using the command: tabulate var1 var2, row

      Lately i used to save my table:

      logout, save(mytablerr) word replace: tab var1 var2, row

      But lamentably the table format in word was wrong, ie for original table from stata:




      Ie, the output from word with incorrect format and wrong cells values:
      +----------------+
      Key
      |----------------|
      frequency
      row percentage
      +----------------+
      femenino masculino Total
      siempre nacional 62 44 106
      58.49 41.51 100
      siempre fdi pto. 36 21 57
      63.16 36.84 100
      siempre otro 1 3 4
      25 75 100
      mixto 10 5 15
      66.67 33.33 100
      Total 109 73 182
      59.89 40.11 100
      Last edited by Rodrigo Badilla; 04 Jun 2016, 09:20.

      Comment


      • #4
        You can try this:
        Code:
        logout, save(table) excel fix replace: tab var1 var2, row
        This would export the table to an excel table that you can copy and paste in a word document. Using the fix option is important in the command line to get the excel table formatted.

        Alternatively, you can select and copy the table from Stata's Result's window and paste it in Excel, select the whole thing on Excel, and from the Data tab, select Text to Columns, and then using the fixed format, you can edit your table.

        Here is a list of other Stata commands that you can install and use for exporting tables:
        http://www.cpc.unc.edu/research/tool...orting_results

        Comment


        • #5
          Thanks Cyrus! this command gave me the best results!...

          Anyway do you know if exist some method to add % sign or add () to percentage values?
          Last edited by Rodrigo Badilla; 04 Jun 2016, 09:55.

          Comment


          • #6
            It is probably easier to automate adding % and ( ) on Excel than doing that in Stata. You can create a column of concatenate formula on Excel with something like:

            Code:
            =concatenate( "(", A1, "%)" )
            Click image for larger version

Name:	Capture.PNG
Views:	1
Size:	5.1 KB
ID:	1343983



            Comment


            • #7
              I found some minutes ago an excellent command to do this, from https://www.ssc.wisc.edu/sscc/pubs/stata_tables.htm :

              estpost tab sum genero

              esttab, cell(b rowpct(fmt(%5.1f) par)) note(Row Percentages in Parentheses) unstack nonumber nomtitle collabels(none) eqlabels(, lhs("result")) varwidth(15)

              Comment


              • #8
                Hi Rodrigo,

                Many thanks for posting the link to that command as it is also exactly what I was after. I just wondered if you knew of a follow up command to save the output table from this>

                Thanks
                Kate

                Comment


                • #9
                  Though I've never used it, tabout appears to have this functionality. tabout is available from SSC (ssc install tabout).
                  See the tabout tutorial for more details.

                  Comment


                  • #10
                    Thanks Arthur Morris

                    Comment


                    • #11
                      I know I am very late, but think there is a more general solution. I was looking this up and saw it was not solved in this thread, so thought it might be helpful to someone googling in the future.

                      You can use the par() option to specify what the parentheses should be, i.e. nothing at the start and the percent symbol afterwards.

                      For a replicable example:
                      Code:
                      sysuse auto, clear
                      estpost tab rep78 foreign
                      
                      esttab . , cell(rowpct(fmt(1) par("" "%"))) unstack
                      
                      ---------------------------------------------------
                                            (1)                          
                                                                        
                                       Domestic      Foreign        Total
                                         rowpct       rowpct       rowpct
                      ---------------------------------------------------
                      1                  100.0%         0.0%       100.0%
                      2                  100.0%         0.0%       100.0%
                      3                   90.0%        10.0%       100.0%
                      4                   50.0%        50.0%       100.0%
                      5                   18.2%        81.8%       100.0%
                      Total               69.6%        30.4%       100.0%
                      ---------------------------------------------------
                      N                      69                          
                      ---------------------------------------------------
                      Last edited by Nick Barton; 11 Jun 2021, 08:21.

                      Comment

                      Working...
                      X