Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

Re: st: date format

From   n j cox <>
Subject   Re: st: date format
Date   Tue, 20 Sep 2005 16:42:09 +0100

The format of the variable, here %dN/D/Y, is essentially a
cosmetic matter. What you should be worried about is whether
some of the values are about a century out, because
of some previous error on reading the data into Stata.

Suppose the variable concerned is called -date-.

count if year(date) < 1910

will reveal how many are a century out. If there are some they need
fixing by

replace date = mdy(month(date), day(date), year(date) + 100) if year(date) < 1910

and you need to revise analyses done with these data.


Terra Curtis wrote

I have a variable of type %dN/D/Y. Some of the dates are in years
2000-2005. When I sort by this variable, Stata seems to recognize some of the 2000-2005 dates as 1900-1905, hence putting them as the earliest date rather than the most recent. Any ideas as to how to get Stata to recognize 01/01/05 as a 2005 date rather than 1905?

* For searches and help try:

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