Stata is a little bit awkward when using
if statement, compared to SAS. For example:
In SAS, we can write
if 2001 <= fyear <= 2010. But in Stata, we usually write:
if fyear >= 2001 & fyear <= 2010.
In fact, Stata provides a handy
inrange function. The above
if statement can be written as:
if inrange(fyear, 2001, 2010).
Similarly, Stata provides another
inlist function. The syntax is
inlist(z, a, b, ...), which returns 1 if z = a or z = b … In
if statement, it is equivalent to
if z = a | z = b | ...