Statalist


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

st: RE: Comment on date formats: Re: statalist-digest V4 #3271


From   "Nick Cox" <n.j.cox@durham.ac.uk>
To   <statalist@hsphsun2.harvard.edu>
Subject   st: RE: Comment on date formats: Re: statalist-digest V4 #3271
Date   Thu, 11 Dec 2008 18:35:20 -0000

A small variant on Allan's code makes use of c(Mons) as evident from
-creturn list-. 

gen nmonth = (strpos("`c(Mons)'", month) + 3)/4

There is no gain in clarity or efficiency, but c(Mons) and c(Months)
have their uses in this territory. 

Clearly both Allan's solution and the variant here break down with
non-English abbreviations. His is adaptable, while the variant here is
not. 

A variable holding integers 1..12 could, and should, be byte. 

Nick 
n.j.cox@durham.ac.uk 

Allan Reese

Moving dates between programs is always problematical.  Both the
software and each user have to act on assumptions.  IMO the only safe
method is to split the date into day, month and year fields.  For data
entry I recommend using month names, then there's no confusion that 9/11
might have happened in November.  I've just written such code using a
pull-down list of month names, converting to the month number by the
equivalent of

gen nmonth = (strpos("JanFebMarAprMayJunJulAugSepOctNovDec", month)+2)/3

Has anyone seen problems of dates confused between AD and AH or other
calendars?


*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/



© Copyright 1996–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index