I would like to convert string data to quarterly dates. I have read and tried to follow much of the advice here:
https://www.statalist.org/forums/for...-date-variable
https://www.statalist.org/forums/for...-to-stata-date
https://www.statalist.org/forums/for...date-variables,
as well as in Chapter 24 and the DateTimeTranslation documentation. None of my attempts are working. I post the simplest of my efforts; I'd appreciate an explanation of my error.
The data:
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input str8 quarter_str "Q12011" "Q12012" "Q12013" "Q12014" "Q12015" "Q22011" "Q22012" end
My code:
Code:
gen quarter = quarterly(quarter_str, "QY")
. gen quarter = quarterly(quarter_str, "QY")
(5,280 missing values generated)
I've also tried different formats for the string variable, and adjusted accordingly. e.g.
"Q1/2011"
"Q1/2012"
. gen quarter = quarterly(quarter_str, "Q#Y")
with the same result: an empty variable generated.
Though I'm a regular consumer, this is my first posting to Statalist, and I will be delighted to have my error pointed out in the simplest terms.
Thanks.
0 Response to Using quarterly() to generate date from string.
Post a Comment