I have quarterly cross-sectional data (isid gvkey date is alright) and want to generate lagged values (the lag is quarterly, or 3 months respectively)
I did the following preparation:
gen date=date(datadate,"YMD")
format date %tm
tsset gvkey date, monthly
sort gvkey date
gen test=L3.ibq
but it only generates missing values for test. Alternatively with delta(3) and test=L.ibq it doesn't work either...
Could someone please help me identifying where the mistake in my process is?
Many thanks in advance!!
Philipp Z-L
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input long gvkey str8 datadate float(date ibq test) 1166 "19980630" 14060 6.37 . 1166 "19990630" 14425 12.201 . 1166 "20010630" 15156 9.3 . 1166 "20040331" 16161 14.88 . 1166 "20040630" 16252 4.359 . 1166 "20040930" 16344 3.692 . 1166 "20041231" 16436 1.395 . 1166 "20050331" 16526 -7.248 . 1166 "20050630" 16617 .518 . 1166 "20050930" 16709 -6.296 . 1166 "20051231" 16801 -27.191 . 1166 "20060331" 16891 10.033 . 1166 "20060630" 16982 18.718 . 1166 "20060930" 17074 13.055 . 1166 "20061231" 17166 12.012 . 1166 "20070331" 17256 11.157 . 1166 "20070630" 17347 14.903 . 1166 "20070930" 17439 15.827 . 1166 "20071231" 17531 19.09 . 1166 "20080331" 17622 12.639 . 1166 "20080630" 17713 -34.706 . 1166 "20080930" 17805 2.421 . 1166 "20081231" 17897 -6.245 . 1166 "20090331" 17987 -23.276 . 1166 "20090630" 18078 -56.549 . 1166 "20090930" 18170 -15.817 . 1166 "20091231" 18262 -11.741 . 1166 "20100331" 18352 4.172 . 1166 "20100630" 18443 51.153 . 1166 "20100930" 18535 34.286 . 1166 "20101231" 18627 24.656 . 1166 "20110331" 18717 40.074 . 1166 "20110630" 18808 54.67 . 1166 "20110930" 18900 80.971 . 1166 "20111231" 18992 15.445 . 1166 "20120331" 19083 6.26 . 1166 "20120630" 19174 23.654 . 1166 "20120930" 19266 4.908 . 1166 "20121231" 19358 -21.733 . 1166 "20130331" 19448 1410.146 . 1166 "20130630" 19539 -23.403 . 1166 "20130930" 19631 -.875 . 1166 "20131231" 19723 -333.975 . 1166 "20140331" 19813 27.137 . 1166 "20140630" 19904 34.598 . 1166 "20140930" 19996 54.564 . 1166 "20141231" 20088 21.009 . 1166 "20150331" 20178 59.988 . 1166 "20150630" 20269 39.862 . 1166 "20150930" 20361 35.707 . 1166 "20151231" 20453 21.719 . 1166 "20160331" 20544 5.358 . 1166 "20160630" 20635 35.576 . 1166 "20160930" 20727 33.058 . 1166 "20161231" 20819 61.479 . 1166 "20170331" 20909 35.863 . 1166 "20170630" 21000 132.122 . 1166 "20170930" 21092 42.211 . 1166 "20171231" 21184 242.206 . 1166 "20180331" 21274 14.954 . 1166 "20180630" 21365 59.408 . 1166 "20180930" 21457 39.096 . 1166 "20181231" 21549 43.676 . 1932 "20010630" 15156 213 . 1932 "20040331" 16161 215 . 1932 "20040630" 16252 255 . 1932 "20040930" 16344 421 . 1932 "20041231" 16436 207 . 1932 "20050331" 16526 428 . 1932 "20050630" 16617 510 . 1932 "20050930" 16709 443 . 1932 "20051231" 16801 390 . 1932 "20060331" 16891 452 . 1932 "20060630" 16982 549 . 1932 "20060930" 17074 446 . 1932 "20061231" 17166 449 . 1932 "20070331" 17256 495 . 1932 "20070630" 17347 584 . 1932 "20070930" 17439 600 . 1932 "20071231" 17531 451 . 1932 "20080331" 17622 599 . 1932 "20080630" 17713 650 . 1932 "20080930" 17805 657 . 1932 "20081231" 17897 551 . 1932 "20090331" 17987 725 . 1932 "20090630" 18078 725 . 1932 "20090930" 18170 631.5 . 1932 "20091231" 18262 631.5 . 1932 "20100331" 18352 762.5 . 1932 "20100630" 18443 762.5 . 1932 "20100930" 18535 677 . 1932 "20101231" 18627 677 . 1932 "20110331" 18717 935 . 1932 "20110630" 18808 935 . 1932 "20110930" 18900 612.5 . 1932 "20111231" 18992 612.5 . 1932 "20120331" 19083 954 . 1932 "20120630" 19174 964.5 . 1932 "20120930" 19266 944.5 . 1932 "20121231" 19358 956 . end format %tm date
0 Response to Lag not working for monthly/quarterly data
Post a Comment