Hi StataForum, I am a relatively new user running loops. I am trying to figure out my error here when I try and run a loop within a loop to group variables by ICD9Code first and then a variable named Verify. I first identifying subjects with hypertension with certain ICD9Codes then assign values to a variable Verify if a subject has the ICD9Code for hypertension Any assistant greatly appreciated.
. foreach n of numlist 1/69 {
2. foreach v in "404" "404.1" "404.1.1" {
3. if icd9code`n' == "`v'" {
4. if verify`n' == 0 {
5. replace eluncomphtnprofile = 1
6. replace eluncomphtnchart = 0
7. }
8. else if verify`n' == 1 {
9. replace eluncomphtnprofile = 1
10. replace eluncomphtnchart = 1
11. }
12. else verify`n' == 2 {
13. replace eluncomphtnprofile = 0
14. replace eluncomphtnchart = 1
15. }
16. }
17. }
18. }
} is not a valid command name
r(199);
Thank you,
Joanna
. foreach n of numlist 1/69 {
2. foreach v in "404" "404.1" "404.1.1" {
3. if icd9code`n' == "`v'" {
4. if verify`n' == 0 {
5. replace eluncomphtnprofile = 1
6. replace eluncomphtnchart = 0
7. }
8. else if verify`n' == 1 {
9. replace eluncomphtnprofile = 1
10. replace eluncomphtnchart = 1
11. }
12. else verify`n' == 2 {
13. replace eluncomphtnprofile = 0
14. replace eluncomphtnchart = 1
15. }
16. }
17. }
18. }
} is not a valid command name
r(199);
Thank you,
Joanna
Comment