Hi,
I would like to merge the following data with panel data (firm/gvkey-year level). Is there a way to extract the earliest year of "facilitystartdate" and latest year of "facilityenddate" within each "packageid" in the data below and change it into panel data at the firm-year level?
For example, I need the original data to be changed to the following format (or something similar):
packageid gvkey dealamount fyear
100 . 50000000 1987
100 . 50000000 1988
100 . 50000000 1989
100 . 50000000 1990
100 . 50000000 1991
100 . 50000000 1992
100 . 50000000 1993
100 . 50000000 1994
100 . 50000000 1995
101 9362 18000000 1987
........
........
Here is the original data:
Thank you very much for your help in advance!!
I would like to merge the following data with panel data (firm/gvkey-year level). Is there a way to extract the earliest year of "facilitystartdate" and latest year of "facilityenddate" within each "packageid" in the data below and change it into panel data at the firm-year level?
For example, I need the original data to be changed to the following format (or something similar):
packageid gvkey dealamount fyear
100 . 50000000 1987
100 . 50000000 1988
100 . 50000000 1989
100 . 50000000 1990
100 . 50000000 1991
100 . 50000000 1992
100 . 50000000 1993
100 . 50000000 1994
100 . 50000000 1995
101 9362 18000000 1987
........
........
Here is the original data:
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input long packageid str10(facilitystartdate facilityenddate) float gvkey double dealamount 100 "09/12/1987" "09/01/1995" . 50000000 100 "09/12/1987" "09/01/1995" . 50000000 100 "09/12/1987" "09/01/1989" . 50000000 100 "09/12/1987" "09/01/1995" . 50000000 101 "08/05/1987" "11/05/1987" 9362 18000000 101 "08/05/1987" "11/05/1987" 9362 18000000 101 "08/05/1987" "11/05/1987" 9362 18000000 102 "09/12/1987" "01/12/1988" . 3.700e+08 102 "09/12/1987" "11/01/1995" . 3.700e+08 102 "09/12/1987" "11/01/1992" . 3.700e+08 103 "09/01/1987" "09/01/1988" . 10000000 104 "09/08/1987" "09/08/1988" . 10000000 105 "09/01/1987" "09/01/1994" 12826 2.4145e+09 105 "09/01/1987" "09/01/1994" 12826 2.4145e+09 105 "09/01/1987" "09/01/1994" 12826 2.4145e+09 105 "09/01/1987" "09/01/1994" 12826 2.4145e+09 105 "09/01/1987" "09/01/1994" 12826 2.4145e+09 105 "09/01/1987" "09/01/1994" 12826 2.4145e+09 105 "09/01/1987" "09/01/1994" 12826 2.4145e+09 105 "09/01/1987" "09/01/1994" 12826 2.4145e+09 105 "09/01/1987" "09/01/1994" 12826 2.4145e+09 105 "09/01/1987" "09/01/1994" 12826 2.4145e+09 105 "09/01/1987" "09/01/1994" 12826 2.4145e+09 105 "09/01/1987" "09/01/1994" 12826 2.4145e+09 105 "09/01/1987" "09/01/1994" 12826 2.4145e+09 105 "09/01/1987" "09/01/1994" 12826 2.4145e+09 105 "09/01/1987" "09/01/1994" 12826 2.4145e+09 105 "09/01/1987" "09/01/1994" 12826 2.4145e+09 105 "09/01/1987" "09/01/1994" 12826 2.4145e+09 105 "09/01/1987" "09/01/1994" 12826 2.4145e+09 106 "10/01/1987" "10/01/1989" . 10000000 107 "08/01/1987" "08/01/1988" 6300 10000000 108 "08/01/1987" "02/03/1988" 6300 15400000 109 "01/12/1987" "01/12/1988" . 600000 110 "09/12/1987" "01/01/1989" 3321 1300000 111 "09/01/1987" "09/01/1990" 6005 80000000 111 "09/01/1987" "03/01/1988" 6005 80000000 112 "09/12/1987" "10/01/1997" 12332 1.900e+08 112 "09/12/1987" "10/01/1997" 12332 1.900e+08 112 "09/12/1987" "10/01/1997" 12332 1.900e+08 112 "09/12/1987" "10/01/1997" 12332 1.900e+08 112 "09/12/1987" "10/01/1997" 12332 1.900e+08 113 "10/01/1987" "10/01/1992" 15242 18000000 113 "10/01/1987" "10/01/1992" 15242 18000000 115 "09/02/1987" "10/01/1988" . 45000000 115 "09/02/1987" "10/01/1988" . 45000000 115 "09/02/1987" "10/01/1988" . 45000000 115 "09/02/1987" "10/01/1988" . 45000000 115 "09/02/1987" "10/01/1988" . 45000000 115 "09/02/1987" "10/01/1988" . 45000000 115 "09/02/1987" "10/01/1988" . 45000000 115 "09/02/1987" "10/01/1988" . 45000000 116 "09/01/1987" "04/01/1997" . 29100000 117 "09/12/1987" "11/01/1992" 4931 52000000 117 "09/12/1987" "11/01/1990" 4931 52000000 118 "09/01/1987" "09/01/1992" 7479 16000000 119 "08/12/1987" "03/01/1989" 8215 2.475e+09 119 "08/12/1987" "03/01/1990" 8215 2.475e+09 119 "08/12/1987" "03/01/1990" 8215 2.475e+09 119 "08/12/1987" "03/01/1990" 8215 2.475e+09 119 "08/12/1987" "03/01/1989" 8215 2.475e+09 119 "08/12/1987" "03/01/1995" 8215 2.475e+09 119 "08/12/1987" "03/01/1995" 8215 2.475e+09 119 "08/12/1987" "03/01/1995" 8215 2.475e+09 119 "08/12/1987" "03/01/1990" 8215 2.475e+09 119 "08/12/1987" "03/01/1995" 8215 2.475e+09 119 "08/12/1987" "03/01/1990" 8215 2.475e+09 119 "08/12/1987" "03/01/1990" 8215 2.475e+09 119 "08/12/1987" "03/01/1990" 8215 2.475e+09 119 "08/12/1987" "03/01/1990" 8215 2.475e+09 119 "08/12/1987" "03/01/1990" 8215 2.475e+09 119 "08/12/1987" "03/01/1995" 8215 2.475e+09 119 "08/12/1987" "03/01/1990" 8215 2.475e+09 119 "08/12/1987" "03/01/1995" 8215 2.475e+09 119 "08/12/1987" "03/01/1990" 8215 2.475e+09 119 "08/12/1987" "03/01/1995" 8215 2.475e+09 119 "08/12/1987" "03/01/1995" 8215 2.475e+09 119 "08/12/1987" "03/01/1995" 8215 2.475e+09 119 "08/12/1987" "03/01/1990" 8215 2.475e+09 119 "08/12/1987" "03/01/1990" 8215 2.475e+09 119 "08/12/1987" "03/01/1995" 8215 2.475e+09 119 "08/12/1987" "03/01/1995" 8215 2.475e+09 119 "08/12/1987" "03/01/1995" 8215 2.475e+09 119 "08/12/1987" "03/01/1995" 8215 2.475e+09 119 "08/12/1987" "03/01/1990" 8215 2.475e+09 119 "08/12/1987" "03/01/1995" 8215 2.475e+09 119 "08/12/1987" "03/01/1990" 8215 2.475e+09 119 "08/12/1987" "03/01/1995" 8215 2.475e+09 119 "08/12/1987" "03/01/1995" 8215 2.475e+09 119 "08/12/1987" "03/01/1989" 8215 2.475e+09 119 "08/12/1987" "03/01/1995" 8215 2.475e+09 119 "08/12/1987" "03/01/1990" 8215 2.475e+09 119 "08/12/1987" "03/01/1990" 8215 2.475e+09 119 "08/12/1987" "03/01/1990" 8215 2.475e+09 119 "08/12/1987" "03/01/1995" 8215 2.475e+09 119 "08/12/1987" "03/01/1990" 8215 2.475e+09 119 "08/12/1987" "03/01/1990" 8215 2.475e+09 119 "08/12/1987" "03/01/1995" 8215 2.475e+09 119 "08/12/1987" "03/01/1990" 8215 2.475e+09 119 "08/12/1987" "03/01/1990" 8215 2.475e+09 end
Comment