Hi, I'm having trouble in running a foreach loop and it keeps showing the invalid name error to me. The commands I used are as following:
global NEWIVB "rfriend hfriend trelat rrelat hrelat"
foreach newivb of global `NEWIVB' {
ta `newivb'
ta `newivb', nolabel
recode `newivb' (1 = 3) (3 = 1) (4 = 0), gen(`newivb'_new)
ta `newivb'_new
}
And the error is like this below:
{ invalid name
r(198);
I'm not quiet sure if I type something wrong here and I'm wondering if anyone could give me a hint on that? Thank you so much!
Related Posts with Invalid name error in foreach loop
Tabulate at least 10 variables having same value labels in one table, displaying value labels percent on columsHello dear experienced Stata users. I am a new Stata user. I have been using it for about 5 months a…
xml_tab does not output required tstat or pvalueI use the following code to output regression results. Code: xml_tab r1, replace drop() below tsta…
Input+end inside a ProgramHi, I like using input/end, in order to easily type data, Code: clear input float var1 1 2 3 4 5 e…
Boottest command for multiple hypothesis testingDear Statalists, Hoping for someone to explain: I want to know whether boottest, a user-written comm…
Calculate percentages across rowsBelow is an example dataset. I want to create multiple columns representing the percentage calculate…
Subscribe to:
Post Comments (Atom)
0 Response to Invalid name error in foreach loop
Post a Comment