Hi! I got this code that allows me to export a simple tabulation of the variable "Edad" to Excel:
tabulate Edad, matcell(freq) matrow(names)
putexcel set "Example 1", modify
putexcel A1=("Pregunta 1") B1=("Frecuencia") C1=("%") D1=("% Acumulado")
local rows = rowsof(names)
local row = 2
local cum_percent = 0
forvalues i = 1/`rows' {
local val = names[`i',1]
local val_lab : label (Edad) `val'
local freq_val = freq[`i',1]
local percent_val = `freq_val'/`r(N)'*100
local percent_val : display %9.2f `percent_val'
local cum_percent : display %9.2f (`cum_percent' + `percent_val')
putexcel A`row'=("`val_lab'") B`row'=(`freq_val') C`row'=(`percent_val') ///
D`row'=(`cum_percent')
local row = `row' + 1
}
putexcel A`row'=("Total") B`row'=(r(N)) C`row'=(100.00)
It works perfectly, the things is that I want to do this same procedure but for the other 35 variables that I have, and also it would be great if I could export the tables in the same Excel file or even the same spreadsheet. I could run the comand 35 five times changing the name of the variable but there must be an easier way to do this, can you point me in the right direction or give me advice on how to proceed?
Thank you very much!
Related Posts with Exporting multiple tabs to Excel with putexcel
Staggered difference in differenceHi, I need to run a difference in difference, but I'm not sure how to construct a formula for this.…
Spatial autocorrelation tests and spatial weight matrix for panel dataHello everyone, I could not find "splagvar" command from my Stata software. I would like to do Mora…
rangestat questionHellow I have a question in rangestat why do I always get the result that never calculates? My mean …
Treatments before running fractional probit modelHi, I am using a dataset for 25 countries over the period of 5 years (balanced panel) with a few mis…
Partial options and excluded instruments in xtivreg2Dear all, I am looking to the impact of immigration on firm level outcomes during the period 2006-2…
Subscribe to:
Post Comments (Atom)
0 Response to Exporting multiple tabs to Excel with putexcel
Post a Comment