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

Re: Export tables to Excel

$
0
0

Hello,
I am trying to use tab2xl to export frequency tables from stata to excel for multiple variables at once. do you have suggestions for a loop that can do this? I have tried

local variables price mpg rep78 headroom trunk weight length turn displacement gear_ratio foreign

local col=1

foreach var of varlist `variables' {

tab2xl `var' using "d:\Users\autah\Desktop\1\test.xls", row(1) col(1) replace

local col=`col'+6

}
..but stata keeps replacing the last table with the next so in the end i end up with only 1 table in my Excel sheet.
Any advice on how to code this so that I have all the tables for all the variables in the same sheet?
Thanks!


Viewing all articles
Browse latest Browse all 1125

Trending Articles