Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
st: If-command not accurate
From
"Daniel Brodback" <[email protected]>
To
[email protected]
Subject
st: If-command not accurate
Date
Tue, 07 Aug 2012 18:26:32 +0200
Dear all,
in a foreach-loop, I am trying to "catch" a specific case and therefore I implement this with an if-command.
For my varlist, I want certain commands to be executed but when var "PF_ret6" occurs, I need different commands.
I implemented this in the following way (Stata SE 11.2):
foreach var of varlist PF_dy-PF_ret6 {
if `var' == PF_ret6 {
...
}
else
{
}
}
The weird behavior is, that for the first variables everything works as expected. But when the variable prior to PF_ret6 is reached (named PF_lret6), it also enters the if-condition.
Is there a way to assure that the if-command only uses PF_ret6 but not PF_lret6?
Kind regards,
Daniel
*
* For searches and help try:
* http://www.stata.com/help.cgi?search
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/