Quantcast
Channel: Statalist
Viewing all articles
Browse latest Browse all 72762

Extract Monthly date from Quarterly date

$
0
0
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

:
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
However, the second command to extract month from q variable returns unexpected values which are not months as one would expect in different quarters.

Viewing all articles
Browse latest Browse all 72762

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>