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)
calculate the number of sharemy data looks like this and I want to calculate how many times did each bank lead in the year for e…
First Differences in VAR ModelsI am currently trying to build a VAR model based off daily stock market returns, exchange rate and t…
Applying HCUP software on NIS data through STATAHello everyone, I'm using NIS data for research, which is a dataset that uses ICD-10 codes to genera…
How to correct/delete observations to create a Panel Data?Hello, I am working with a panel data comprising of two waves written as Survey 1 and 2. The observ…
Which test to use in Stata? Relationship Wage Gender EducationHello, a very naive and at the same time simple question: For a project in statistics where we wan…
Subscribe to:
Post Comments (Atom)
0 Response to _= invalid name r(198)
Post a Comment