Announcement

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

  • Regression and putexcel with parentheses

    Hi, I'm pretty sure I'm not the first one asking this but after a couple of hours I couldn't figure it out how to solve it. I want to put the SE of a regression between parentheses. This is a chunk of my code.

    Code:
    matrix matrix_excel = J(30,26,.)
    putexcel set "path/path",  modify
    Then I run a regression and I do something like


    Code:
    mat fe_1 = r(table)
    
    matrix matrix_excel[`m'+3,1] =  fe_1[2,1]
        
    putexcel `theLetter'1 = matrix(EP_beta)
    But I would like to have the " fe_1[2,1]" between parentheses. (actually my code works through a loop. I tried to make it shorter to show the point). Any suggestions? Thanks !

  • #2
    Maybe you will find this helpful. The clue is that if you want to have parentheses you will have the store the contents in a local first because Stata matrices cannot contain string values.
    Code:
    sysuse auto
    reg price weight
    mat rtable = r(table)
    putexcel set myfile, replace
    putexcel A1 = rtable[1,1]
    local se_par = "(" + string(rtable[1,2], "%4.3f") + ")"
    putexcel A2 = "`se_par'"
    Last edited by Wouter Wakker; 26 Jan 2021, 08:27.

    Comment

    Working...
    X