How to generate quarterly in Stata, Creating Quarterly Variable in Stata.
First set observations to 100 using the following command:
set obs 100
Second, generate the variable name "quarter":
generate quarter = tq(2010q1) + _n-1
Then format to:
format %tq quarter
Note:
tq is the quarterly format in time series data.
2010q1 is the year 2010 and quarter 1.
_n is the serial number, here is 1 to 100.
when we use _n - 1 for 1st observation is 1-1 = 0.
use command:
display tq(2010q1)
The result is 200 when we 200+0 = 200 that's the 1st quarter of 2010.
For the second observation: 200+2-1 = 201, when format 201 into quarter format is the second quarter of 2010.
Try to check:
display tq(2010q2)
The result is 201.
Have a nice day.
Comments
Post a Comment