Hi, I'm just getting back into Stata after a long illness, so I could use some help. I'm trying to run the following code to output proportions to an excel file. It runs through A`'j' but fails at C`j' and returns error code _=invalid name r(198). Can anyone suggest a fix?
Here's my code:
local j = 2
foreach v of varlist agecat gender education incomecat race {
svy,subpop(if child==1): prop `v',over(year)
matrix results = r(table)
matrix results = results[1...,1...]'
putexcel set "$results\Table 1.xlsx", sheet("Categorical vars") modify
putexcel A`j' = "`v'"
local l = rowsof(results)
forvalues `i' = 0(1)`l' {
local i = `i' + 1
local j = `j' + 1
putexcel C`j' = results[`i',1] J`j' = results[`i',2]
/*Above is the point of failure at C`j'*/
local i = `i' + 1
putexcel D`j' = results[`i',1] K`j' = results[`i',2]
local i = `i' + 1
putexcel E`j' = results[`i',1] L`j' = results[`i',2]
local i = `i' + 1
putexcel F`j' = results[`i',1] M`j' = results[`i',2]
local i = `i' + 1
putexcel G`j' = results[`i',1] N`j' = results[`i',2]
local i = `i' + 1
putexcel H`j' = results[`i',1] O`j' = results[`i',2]
}
local j = `j' + 2
}
Related Posts with _= invalid name r(198)
Problem with summing using CollapseHi - I'm having a problem with the Collapse command when I try to obtain the sum of variables. My da…
3 plots gathered in 1 subplotHi, I am struggling to gather 3 plots in 1 unique figure with 3 subplots. I want the subplots to de…
Difference-in-means tests for the propensity-matched sampleIs there an efficient way in Stata to report the results of difference in means tests on propensity …
xtpcse and xtgls with fixed effectsHello community: I want to robustly estimate (xtgls) a panel data model, for both FE and RE. The fol…
Is it possible to add _ to the variable used in by() when collapsing to simplify ability to perform search for said variablesUpdate: Title should refer to -reshape- not -collapse- I've performed a collapse to obtain a number…
Subscribe to:
Post Comments (Atom)
0 Response to _= invalid name r(198)
Post a Comment