I have Stata code to read a bunch of .csv files. I read a variable's data (one column) then I merge it with what I have. Then I try and get it to repeat. I know lines 3 through 10 work.
local md="0301"
while `md'<="0331" {
insheet using "Model_11.2.1_2020`md'_results.csv", clear
gen pvi_`md'=toxpiscore
keep name pvi_`md'
sort name
merge 1:1 name using pvi_scores
drop _m
sort name
save pvi_scores, replace
local md=`md'+1
}
Simplified to where I think the error is
local md="0301"
while `md'<="0331" {
local md=`md'+1
}
I get the r(109) error. So I think the
local md = `md' + 1
is the issue. Is it a string plus a number that causes the issue?