Announcement

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

  • Using putexcel to output titles in multiple columns on sample statistics

    I'm attempting to generate ~40 sets of sample statistics, and as such would like to have Stata output the name of each series into excel. My current code looks like this:

    //INPUTS
    local Peer1 PEER1_PV_PS PEER1_PV_PE PEER1_PV_EVEBITDA PEER1_PV_EVEBIT
    local ncol = 2
    local nrow = 2

    //LOOP
    local col1: word `ncol' of `c(ALPHA)'
    local ++ncol
    foreach var in `Peer1'{
    local name1 `var'
    summarize `var', detail separator(0)
    local col: word `ncol' of `c(ALPHA)'
    putexcel `col'`nrow'=(`name1') `col1'`nrow'=rscalarnames `col'`nrow'=rscalars using"V:\SummaryStats.xlsx", modify
    local ++ncol
    }

    Where each of PEER1_PV_PS PEER1_PV_PE PEER1_PV_EVEBITDA PEER1_PV_EVEBIT are series (of which there are at ~40 of), and the sections in green are those which I'm having issues with.

    The current output looks like this:
    Click image for larger version

Name:	Capture.PNG
Views:	2
Size:	33.7 KB
ID:	1378085


    The output I want looks like this:
    Click image for larger version

Name:	Capture.PNG
Views:	1
Size:	33.8 KB
ID:	1378084

Working...
X