Dear Statalisters:
I am attempting to create a "season" variable based on a date variable.
The solstice start dates are Dec-21, Mar-21, Jun-21 and Sep-22 for
Winter(1), Spring(2), Summer(3) and Autumn(4) respectively. I have
tried to accomplish this using a rather long series of logical operators
such as:
gen month=month(date)
gen day=day(date)
gen season=1 if (month>=12 & day>=21) | (month>=1 & (month<=3 & day<20))
...
However, this code is not correct as it excludes all days>=20.
Rather than adding more logical operators to condition upon the dates, I
was wondering if anyone has a suggestion for a cleaner, more elegant
code.
Thanks,
Thomas
--
Thomas Speidel
Statistical Associate
Clinical Trials Unit
Tom Baker Cancer Centre
1331 - 29th Street N.W.
Calgary, AB, T2N 4N4
Tel. (403) 521-3370
Email: [email protected]
This e-mail and any attachments may contain confidential and
privileged information. If you are not the intended recipient,
please notify the sender immediately by return e-mail, delete this
e-mail and destroy any copies. Any dissemination or use of this
information by a person other than the intended recipient is
unauthorized and may be illegal.
*
* For searches and help try:
* http://www.stata.com/support/faqs/res/findit.html
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/