Announcement

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

  • Combining Tabout and Putexcel for exporting Transition Matrices and Trace

    Hello everyone,
    I am currently working on a rotating panel, survey data with weights, trying to produce:
    • Transition Matrices for employment status
    • Trace of the Transition Matrix.
    I then would need to export both results in an Excel.
    This is achieved by applying the following code:
    Code:
    svy: tab lemployment_status employment_status, row se ci deff
    local i = 1
    matrix lagf = J(7,7,.) 
    forvalues row=1/7{
            forvalues col=1/7{
                matrix m =e(b)
                matrix lagf[`row',`col'] = m[1,`i'] 
                local i = `i' + 1
            }
    } 
    matrix list m
    matrix list lagf
    scalar lagtrace = trace(lagf)
    scalar list lagtrace
    tabout lemployment_status employment_status using indicator6_7.xlsx, append svy    cells(row se lb ub)    format(2c 3c 2c 2c) sebnone pop nwt(WEIGHTVAR)           
    putexcel set "indicator6_7.xls", modify sheet("Mobility Index")    
    putexcel A13 = ("Trace of matrix")
    putexcel B13 = `lagtrace'
    All coding for generating the matrix and the trace work smoothly. Transition matrices are correctly exported through Tabout but Putexcel seems unable to access the excel file for exporting the trace, I get the following error message from STATA:
    Code:
    putexcel A13 = ("Trace of matrix")
    workbook indicator6_7.xls could not be loaded
    r(603);
    Thanks everyone
Working...
X