[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]
Re: st: decimal years
If you want to -tsset-, consider using the obs# instead of the date
(-sort event1-, -gen obs=_n-, then -tsset obs-), for various reasons.
Also, it looks like your date variable is incorrectly defined. 1932
had 366 days, so day 105 of 1932 would be 1932.2869 and day 106 would
be 1932.2896, but you show a date of 1932.2880 which identifies a time
of day as well (perhaps the final zero is false precision, and someone
divided every day-of-year number by 365 so day 105 is coded as
1932.28767 or 1932.288 in your example, which means Dec 31, 1932 will
appear to be in 1933).
Even assuming your date variable has no such problems, Jeph's code
will not work as advertised, but the general strategy works:
g nd= mdy(1,1,y)+d-1
format nd %d
l, noo clean
On 8/11/06, Jeph Herrin <email@example.com> wrote:
Oops, that third line should be reversed or even simplified:
Jeph Herrin wrote:
> If your variable is -date-, the only tricky part is getting
> the number of days in the year.
> Caleb Southworth wrote:
>> How can decimal years be read into stata? The data are %9.4f and identify
>> year, month and day, for example
>> I would like to be able to extract the mdy and to be able to tsset my
>> data, the latter requiring integers.
* For searches and help try: