[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" <>
To   <>
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

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


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

*   For searches and help try:

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