Hi STATA experts,
I am using foreach to run a loop for a list of string variables. The command runs but returned an error message at the end, any advice on how to correct the command is highly appreciated (variable obstcomp* include obstcomp1 to obstcomp16, which store the disease code consisted of one letter and numbers):
foreach var of varlist obstcomp*{
replace hypertension=1 if `var'=="O11" | `var'=="O12" | `var'=="O120"
> | `var'=="O121" | `var'=="O122" | `var'=="O13" | `var'=="O14" | `var'=="O140" | `var'==
> "O141" | `var'=="O142" | `var'=="O149" | `var'=="O15" | `var'=="O150" | `var'=="O151" |
> `var'=="O152" | `var'=="O159" | `var'=="O16"
}
(12,166 real changes made)
(2,702 real changes made)
(647 real changes made)
(150 real changes made)
(35 real changes made)
(2 real changes made)
(0 real changes made)
type mismatch
r(109);
end of do-file
Thank you very much in advance.
Lan
Related Posts with Help with foreach of string variables
Gravity Equation for Trade | Merging panel datasetsHi all, I have a dataset from CEPII (gravdata.dta) which I have cleaned up to contain only specific…
ppmlhdfe and ppml provide different fitted valuesHello, I am running a gravity model thus from (Yotov2016) Code: ppml trade EXPORTER_TIME_FE* IMPORT…
Interpretation stata resultsHello, I'm doing a master thesis on the effect of CSR contracting on CSR performance. My model is b…
finding duplicate values between two variablesDear all, I am using Stata 15 and for my panel data I have director IDs (Director_ID) and the CEO I…
No standard errors reported for some variables when using xtlsdvcHello, I am trying to use xtlsdvc to correct for the bias in the dynamic panel model. However, I d…
Subscribe to:
Post Comments (Atom)
0 Response to Help with foreach of string variables
Post a Comment