Dear forum,
Im struggling to learn how to use the foreach loop using a string variable with several values as indicator var for regression. The examples I have found so far have been very intricate and not exactly what I was looking for.
In the example below, imagine that I just want to use each value in "drug" as an indicator variable and display each of them.
How do I do that?
Thank you so much for advise and tips!
---
Im using stata 17 for windows
Im struggling to learn how to use the foreach loop using a string variable with several values as indicator var for regression. The examples I have found so far have been very intricate and not exactly what I was looking for.
In the example below, imagine that I just want to use each value in "drug" as an indicator variable and display each of them.
How do I do that?
Code:
sysuse cancer,clear
tab drug,miss
*two different aproaches I have tried
*method 1
foreach x of varlist drug {
display "`x'"
}
*method 2
foreach y in drug {
display "`y'"
}
---
Im using stata 17 for windows

Comment