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
Constant term omitted without specifying "nocons", helpI ran a logit regression and the constant term was missing. How can this be? xtlogit vigact3 years …
Merging datasets togetherI am currently in a tricky situation. I have a dataset with 83,311 observations and 109 variables. I…
Fixed Effects at individual-area-level?Hello folks! I have read this paper today: http://ftp.iza.org/dp9311.pdf If you scroll to page 11,…
Box-tidwell testI am doing a logistic regression analysis with Lyme disease (borrelia) as dependent variable. I want…
Reporting contrasts of marginal effects from logit/probit modelsLet's say I have a model to predict the probability of an outcome, and I am interested in reporting …
Subscribe to:
Post Comments (Atom)
0 Response to Exporting multiple tabs to Excel with putexcel
Post a Comment