At 11:20 PM 3/5/2004 -0500, Richard Williams wrote:
Whoops. I think the original solution I posted quickly gets off a
day. I think it is fixable, but how about this instead:
. gen finyear = year(datevisit)
. replace finyear = finyear - 1 if month(datevisit) < 4
Just a quick note to note, as it were, that this approach can be done in
one line:
. gen finyear = year(datevisit) - (month(datevisit)<4)
(This works because the logical condition will evaluate to 0 or 1, as
appropriate.
--Nick Winter
I had tried to do something like that but it wasn't working because I
didn't have the parentheses on the final part of the expression right. For
those determined to use as few lines as possible, here is yet another
spacesaver: