While I was trying to set up a monthly Dynamic Panel Data in Stata:
clear all
drop _all
cls
scalar mnpe = 3
scalar cssize = 6
scalar ldataset = mnpe * cssize
set obs `=ldataset'
//Define variables for the Timewindow to be analized
scalar tstart = 480 //From: 2000/January
scalar tend = `=tstart' + `=cssize' //To : 2000/June
//Generate id and time for the Dynamic Panel
egen id = seq(), block(`=cssize')
egen time = seq(), from(`=tstart') to(`=tend')
format %tm time //Period definition tm: monthly
//Declare THE Dynamic Panel
tsset id time, monthly //Period definition : monthly
//Generate endogenous & exogenous variables
gen y = rnormal(5,1)
gen x1 = rnormal(10,1)
//List them up, by id
list, sepby(id)
xtline x1, tlabel(#3) overlay
I came across with the following missing time data:
+-----------------------------------+
| id time y x1 |
|-----------------------------------|
1. | 1 2000m1 3.821689 10.56352 |
2. | 1 2000m2 4.572973 12.12826 |
3. | 1 2000m3 5.798653 8.558586 |
4. | 1 2000m4 8.021777 12.33319 |
5. | 1 2000m5 3.917288 9.168543 |
6. | 1 2000m6 4.780022 10.94 |
|-----------------------------------|
7. | 2 2000m1 4.70402 9.462132 |
8. | 2 2000m2 4.164953 11.23561 |
9. | 2 2000m3 7.09228 10.03154 |
10. | 2 2000m4 4.429367 10.36254 |
11. | 2 2000m5 3.171889 9.664372 |
12. | 2 2000m7 4.455237 10.33883 |
|-----------------------------------|
13. | 3 2000m1 3.643499 12.20954 |
14. | 3 2000m2 4.201683 9.507583 |
15. | 3 2000m3 4.809181 11.44474 |
16. | 3 2000m4 5.51936 10.25571 |
17. | 3 2000m6 5.279757 9.676065 |
18. | 3 2000m7 5.379889 11.40392 |
+-----------------------------------+
As you can see, there are missing months. Not sure what exactly is going on, though I don't think is the discrepancy due to daylight savings time.
There is no glitch - the value in your scalar tend
is wrong.
You need to subtract 1
from it:
clear
scalar mnpe = 3
scalar cssize = 6
scalar ldataset = mnpe * cssize
set obs `=ldataset'
scalar tstart = 480
scalar tend = `=tstart' + `=cssize' - 1
egen id = seq(), block(6)
egen time = seq(), from(`=tstart') to(`=tend')
format %tm time
This produces the desired result:
list, sepby(id)
+-------------+
| id time |
|-------------|
1. | 1 2000m1 |
2. | 1 2000m2 |
3. | 1 2000m3 |
4. | 1 2000m4 |
5. | 1 2000m5 |
6. | 1 2000m6 |
|-------------|
7. | 2 2000m1 |
8. | 2 2000m2 |
9. | 2 2000m3 |
10. | 2 2000m4 |
11. | 2 2000m5 |
12. | 2 2000m6 |
|-------------|
13. | 3 2000m1 |
14. | 3 2000m2 |
15. | 3 2000m3 |
16. | 3 2000m4 |
17. | 3 2000m5 |
18. | 3 2000m6 |
+-------------+