If your variable is -date-, the only tricky part is getting
the number of days in the year. Try:
gen year = round(date,0)
gen daysinyear=mdy(1,1,year)-mdy(12,31,year)
gen day = round((date-year)*daysinyear,0)
gen newdate=mdy(1,1,year)+day
Then -newdate- should contain the date in Stata's elapsed date format.
HTH,
Jeph
Caleb Southworth wrote:
How can decimal years be read into stata? The data are %9.4f and identify
year, month and day, for example
event1
1932.2880
1949.0410
1939.4270
I would like to be able to extract the mdy and to be able to tsset my
data, the latter requiring integers.
Caleb
[email protected]
University of Oregon Sociology
*
* 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/
*
* 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/