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
Matching loan data with firms dataDear Stata community readers, I’m matching firms loan data with firms accounting data in an internat…
Theoretical Standard Normal Cumulative Distribution in StataHello everyone, I am looking to compare an empirical standard normal cumulative distribution that I …
SFTFE command errorHi, I am trying to run the command "SFTFE" for the stochastic frontier function with heteroscedastic…
50th Percentile Matrix not storing valuesLooking to store my 50th percentile values in a matrix that loops for n= 10, 100, 1000, 10000 observ…
Plotting coefficients using marginsplotHello Statalist users, I run the following code to produce this figure: Code: eststo: reghdfe…
Subscribe to:
Post Comments (Atom)
0 Response to Exporting multiple tabs to Excel with putexcel
Post a Comment