Monthly Archives: November 2017

  • 0

Stata Dates: Conversion from one format to another


Case 1: From String to Stata format

Usually, when we import data manually into the Stata Editor, the dates are shown in string format. For example, Nov202011, November202011, or  etc. We can use the gen command with date function

gen newdate = date(oldDate, "MDY")


Case 2: From daily to monthly

gen monthly = mofd(daily_date)


Case 3: From daily to weekly

gen monthly = wofd(daily_date)

Case 4: From daily to quarterly

gen monthly = qofd(daily_date)


Case 5: From daily to yearly

gen monthly = year(daily_date)


Case 6: From monthly to daily

If our date is recorded in monthly numeric format such as 2001m1, 2001m2, etc, then:

gen daily = dofm(monthly_date)