Announcement

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

  • Exporting logistic regression tables to Excel using putexcel - transposing problem

    Hi everyone!
    I need some comment/suggestions on exporting multiple tables to excel using the putexcel commant.

    I am creating lots of multivariate logistic regression tables that I want to export to excel. I am using the putexcel command and it works perfectly fine when I export one table at a time. I use the following syntax:

    xi: clogit depvar var1 var2, group() or
    putexcel A2=(e(cmdline)) B4=matrix(r(table)', names) using results.xlsx

    xi: clogit depvar var1 var2 var3, group () or
    putexcel A12=(e(cmdline)) B14=matrix(r(table)', names) using results.xlsx, modify

    ...
    ...



    The exported tables look like the original Stata13 tables; the variables are in rows and the coefficients in columns. Which is the layout I like the most.


    ​However, when I try exporting more than one table at a time, all variables, coefficients and values are transposed. I mean, variables are now in columns and the coefficients in rows. This layout is not the best one when you have to show long tables with 3-4 different models with 6-10 varialbes each. The syntax I run in this case is the following:

    xi: clogit depvar var1 var2, group () or
    matrix A = r(table)
    xi: clogit depvar var1 var2 var3, group () or
    matrix B = r(table)
    ...
    ...

    putexcel A2=(e(cmdline)) B4=matrix(A, names) using results.xlsx
    putexcel A12=(e(cmdline)) B14=matrix(B, names) using results.xlsx, modify
    ...



    I do not understand what I am doing wrong or why Stata is transposing the tables. Does anyone have a suggestion on how to export several tables with the same layout Stata shows? I will really appreciate any comment because it is time consuming to export tables one by one, or transposing the exported tables back to the original layout.

    Thank you very much.

    Javier Cotignola
    Last edited by jcotignola; 13 Jan 2015, 14:17.

  • #2
    Javier,

    A couple of comments:

    1. -xi- was superseded by factor variable notation. You should read carefully -help xi- and -help fvvarlist-. The command -clogit- allows factor variable notation (as indicated by its help file) so you should probably be using that.

    2. I don't use -putexcel-, but if you really want to get into the business of making regression tables, try the user-written command -estout-. You need to download it from SSC:

    Code:
    ssc install estout
    Then check its help files. My opinion is that it may seem a bit overwhelming at first glance, but it is well documented and presents many useful options. It's worth learning how to use.
    You should:

    1. Read the FAQ carefully.

    2. "Say exactly what you typed and exactly what Stata typed (or did) in response. N.B. exactly!"

    3. Describe your dataset. Use list to list data when you are doing so. Use input to type in your own dataset fragment that others can experiment with.

    4. Use the advanced editing options to appropriately format quotes, data, code and Stata output. The advanced options can be toggled on/off using the A button in the top right corner of the text editor.

    Comment


    • #3
      Thank you Roberto. I will try estout. I am using factor variables in my models. I really appreciate your comments.

      Comment


      • #4
        Javier: I would second Robert's advice. In fact, the learning curve with -estout- is perhaps less than he intimates. When you install -estout-, you also get -esttab- (-help esttab-), which is a user-friendly front end providing much functionality directly. (Also the documentation on the program's webpages -- link somewhere in the -estout- help file I recall -- has lots of examples including neat stuff you mightn't think you could do.) PS welcome to the Forum. It'd be appreciated if you'd re-register to use your fullname (firstname familyname), as per FAQ recommendation. It's easy -- hit the Contact Us link below right, and make the request. Thanks.

        Comment

        Working...
        X