|
. input ///
> code year month y x
code year month y x
1. 1 1999 3 1 123
2. 1 1999 12 1 1234
3. 1 2000 12 1 324
4. 2 1999 3 23 34
5. 2 1999 6 2312 23
6. 2 1999 12 3234 234
7. 3 2000 12 123 23
8. end
.
. //the idea is to convert date from YM form to YQ form
. gen q=yq(year,quarter(mdy(month,15,year)))
. format q %tq
. l
+--------------------------------------------+
| code year month y x q |
|--------------------------------------------|
1. | 1 1999 3 1 123 1999q1 |
2. | 1 1999 12 1 1234 1999q4 |
3. | 1 2000 12 1 324 2000q4 |
4. | 2 1999 3 23 34 1999q1 |
5. | 2 1999 6 2312 23 1999q2 |
|--------------------------------------------|
6. | 2 1999 12 3234 234 1999q4 |
7. | 3 2000 12 123 23 2000q4 |
+--------------------------------------------+
.
. xtset code q
panel variable: code (unbalanced)
time variable: q, 1999q1 to 2000q4, but with gaps
delta: 1 quarter
.
end of do-file
|