Hi I am trying to right a loop to export a number of tables using putexcel. But my code is not working. I have a number of variables that I would like to crosstab with other several variables. And would like to export these crosstabs to excel file.
I would like to see my tables in excel something like this.
I have been trying the following code to develop basic version of tables but its not working and exports only first table.
Please help of suggest some reference.
putexcel set "D:\Rakesh\CV\FREQS.XLS", sheet(unions)
foreach x of varlist occupation union{
tab `x' race, matcell(cellcounts)
local TotalCount = r(N)
local RowCount = r(r)
local ColCount = r(c)
forvalues row = 1/`RowCount'{
forvalues col = 1/`ColCount'{
local CellContents = cellcounts[`row',`col']
local Cell = char(64 + `col') + string(`row')
putexcel `Cell' = "`CellContents'"
loc w=`RowCount'+2
}
}
}
Thanks in advance.
I would like to see my tables in excel something like this.
Predictor Variable | Wasted | Stunted | ||||
Wealth Index (Low) | 10.6 | 14.3 | 11.83 | 21.2 | 25.2 | 22.53 |
(1.04) | (1.97) | (0.89) | (1.73) | (2.42) | (1.39) | |
Wealth Index (Medium) | 12.6 | 10.6 | 11.83 | 21 | 24.9 | 22.53 |
(1.35) | (1.34) | (0.89) | (1.74) | (1.96) | (1.39) | |
761 | 505 | 1266 | 762 | 506 | 1268 | |
Wealth Index (High) | 12.3 | 10.7 | 11.83 | 25 | 16.2** | 22.53 |
(1.01) | (1.65) | (0.89) | (1.58) | (2.83) | (1.39) | |
Residence | 11 | 14.2 | 11.83 | 23.2 | 20.5 | 22.53 |
(0.98) | (1.86) | (0.89) | (1.38) | (3.72) | (1.39) | |
Gender | 11.5 | 12.1 | 11.83 | 24.7 | 20.2 | 22.53 |
(1.16) | (1.32) | (0.89) | (1.71) | (1.94) | (1.39) | |
HH size | 18.1 | 10.8* | 11.83 | 23.1 | 22.4 | 22.53 |
(3.21) | (0.87) | (0.89) | (3.34) | (1.55) | (1.39) |
Please help of suggest some reference.
putexcel set "D:\Rakesh\CV\FREQS.XLS", sheet(unions)
foreach x of varlist occupation union{
tab `x' race, matcell(cellcounts)
local TotalCount = r(N)
local RowCount = r(r)
local ColCount = r(c)
forvalues row = 1/`RowCount'{
forvalues col = 1/`ColCount'{
local CellContents = cellcounts[`row',`col']
local Cell = char(64 + `col') + string(`row')
putexcel `Cell' = "`CellContents'"
loc w=`RowCount'+2
}
}
}
Thanks in advance.
Comment