Hans J. Baumgartner wrote:
> Dear statalist,
>
> within a foreach-loop I would like to add loop-specific routines. I.e.:
>
> foreach x in one two {
> some fancy commands
> if `x’=="one" {
> do this
> }
> if `x’=="two" {
> do that
> }
> some other fancy commands
> }
If you want to check whether `x' contains the _string_ "one", you need to put
quotes around `x':
foreach x in one two {
some fancy commands
if "`x’"== "one" {
do this
}
if "`x’" == "two" {
do that
}
some other fancy commands
}
--
[email protected]
+49 (030) 25491-361
*
* For searches and help try:
* http://www.stata.com/support/faqs/res/findit.html
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/