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: multiple conditions using an if statement?
From
Michael Betz <[email protected]>
To
"[email protected]" <[email protected]>
Subject
st: multiple conditions using an if statement?
Date
Fri, 22 Feb 2013 23:13:25 +0000
Hi all--Is it possible to have multiple conditions using an if statement?
I'm trying to create several variables and sum all but two of them.
Here's my code:
foreach e in aborig afr asia can camer carber euro namer nonabor ocean samer{
gen `e'_grt=pob_`e'+poc_`e'
if "`e'"!="aborig" | "`e'"!="nonabor" replace sum_grt=sum_grt+`e'_grt
}
It executes, but does not perform the second part of the if command beyond the "or" operator ("`e'"!="nonabor"). It sums all the variables except the "aborig" one, but I need it to sum all the variables except both "aborig" and "nonabor". Am I doing something illegal here?
Thanks,
Mike
*
* For searches and help try:
* http://www.stata.com/help.cgi?search
* http://www.stata.com/support/faqs/resources/statalist-faq/
* http://www.ats.ucla.edu/stat/stata/