I had posted a day ago to extract date from string. While Nick solved that, but it created another problem, i.e. monthly date cannot be extracted from quarterly date , see what I tried
However, the second command to extract month from q variable returns unexpected values which are not months as one would expect in different quarters.
:
clear input str7 date "1984 Q1" "1984 Q2" "1984 Q3" "1984 Q4" "1985 Q1" "1985 Q2" "1985 Q3" "1985 Q4" "1986 Q1" "1986 Q2" end gen q=quarterly(date, "YQ") gen ym=ym(year(q), month(q)) format ym %tm