Converting string date variable to numeric date variable

77 views
Skip to first unread message

dgaze...@gmail.com

unread,
Feb 25, 2016, 9:48:59 AM2/25/16
to Stata Users Forum
Hello,

The attached file contains Amtrak ridership by month. As you can see, the month column is formatted as follows:

month
Feb-91
Mar-91
Apr-91
.
.
.
Mar04

When I copy and paste the data into Stata, the month is formatted as a string date variable and I'm ultimately trying to convert to a numeric string variable for time series analysis. My initial instinct was to accomplish this with gen month2 = date(month,"MDY") but this isn't going to work because I don't have days. I then tried gen month2 = date(month,"MY") and this returned blank values. Does anyone have any recommendations keeping in mind the fact that 1) the year is only 2-digits and 2) we're dealing with two centuries (19YY and 20YY)?

Thanks,

Dave
 
Amtrak.xlsx
Reply all
Reply to author
Forward
0 new messages