Stata is a little bit awkward when using and
and or
in 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 | ...
Dear Professor, I want to make descriptive statistics for the pre and post period. The Data period is 2015to 2019. the pre-period is 2015&2016 while the post period is 2018&2019. Kindly, give us some insight on it.
Regards Sattar Khan