Statalist


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

Re: st: Using a date in a condition


From   "Joseph Coveney" <[email protected]>
To   "Statalist" <[email protected]>
Subject   Re: st: Using a date in a condition
Date   Thu, 21 Feb 2008 00:13:12 +0900

Herve STOLOWY wrote:

In a data set, one variable (fyr) is the date of the financial year end.
The current displayed format is, e.g., 31 Dec 04, 30 Jun 04, 30 Sep
05... When  I click on the year end, I see a figure (e.g., 16252). I
understood, reading the Stata documentation, that the format I am using
is that of elapsed dates. I understand the principle.

I need to use the date as a condition in:

replace year2 = 07 if fyr== 31 Dec 04

This does not work. (I also tried with quotes around the date). I guess
that it is because of the date format but can't find a solution in the
help file on dates.

Would you have any idea?

--------------------------------------------------------------------------------

In Stata Release 10:

replace year2 = 07 if fyr == date("31 Dec 04", "DMY")

In earlier releases:

replace year2 = 07 if fyr == date("31 Dec 04", "dmy")

Joseph Coveney


*
*   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/



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