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
Calculating percentiles in STATAHi, I am using the following loop to get the 0.5%, 1%, 2%, 5%, 95%, 98%, 99% and 99.5% percentiles f…
using DHS DATA SET for cluster fixed effect Hello every one, Please I am new in stata, I am trying to construct a cross sectional data set fro…
estat vce, corr and vifI apologise in advance if this has been posted before. Though I couldn't seem to find a discussion w…
margins- marginal effect of time-variant variables in mixed effects modelsDear Statalist users, I am using Stata 14 SE, and have a question about using margins for a time-var…
how to calculate marginal effect?Hi there, Need some help calculating marginal effect. Variable Description sid Subject ID age…
Subscribe to:
Post Comments (Atom)
0 Response to Exporting multiple tabs to Excel with putexcel
Post a Comment