Quantcast
Channel: The Stata Blog - Latest Comments
Viewing all articles
Browse latest Browse all 1129

Re: Creating Excel tables with putexcel part 3: Writing custom reports for arbitrary variables

$
0
0

Hi Chuck,

I'm using putexcel and very similar nested loop as those shown above. It's running a fair bit slower than I would have expected. I'm outputting about 15 columns and 100 rows of text and data to create an automated report. This is taking over an hour at times. Any ideas of why it could be running slow or suggestions for speeding it up?

It looks like this:

putexcel set "..\Output\Tableset 2.xlsx", sheet("`outcome'", replace) `update'

local charnum = 97
local rows = _N
local outrows = `rows'+3

* Title and subtitle
putexcel A1 = "`title'"

putexcel A2 = "`subtitle'"

* Main body
foreach var of varlist v1-v22 {
noi display "exporting variable: `var'"
forvalues row = 1/`rows' {
local outrow = `row'+3
local col = char(`charnum')
local val = `var'[`row']
putexcel `col'`outrow' = "`val'"
}
local ++charnum
}


Viewing all articles
Browse latest Browse all 1129

Trending Articles