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)
Event Study Graph: Do I need an indicator variable for each pre and post treatment period (except t-1)? Code: * Example generated by -dataex-. For more info, type help dataex clear input float(id monthl…
export spatial weight matrixHi, I'm exploiting district-level unbalanced panel data. I used the following command to generate a…
How to Count the Number of the Students Having Grade Retention in a Dataset in Stata Code?As the title suggested, I would like to count the number of the students who had grade retention in …
Reshape wide to long - datasetHello, I need to organize my data and convert it from wide to long. Since I have to many variables …
Calculando o coeficiente de GiniBoa tarde pessoal, estou tentando calcular o índice de gini para alguns setores da economia, identif…
Subscribe to:
Post Comments (Atom)
0 Response to _= invalid name r(198)
Post a Comment