Dear all,
Hi, I have a panel data (CRSP mutual fund database), where crsp_fundno identifies a mutual fund and qdatev identifies the quarterly observation time. I am interested in expense ratio (exp_ratio) data point. For example, the following sample lists expense ratio for mutual fund crsp_fundno==53 from 3rd quarter of 1992 to end of 1994
+------------------------------+
| crsp_fundno qdatev exp_ratio | WANTED VARIABLE
|------------------------------|
67. | 53 1992q3 .0091 | 2
68. | 53 1992q4 .0091 | 2
69. | 53 1993q1 .0084 | 4
70. | 53 1993q2 .0084 | 4
71. | 53 1993q3 .0084 | 4
|------------------------------|
72. | 53 1993q4 .0084 | 4
73. | 53 1994q1 .0072 | 12
74. | 53 1994q2 .0072 | 12
75. | 53 1994q3 .0072 | 12
76. | 53 1994q4 .0072 | 12
|------------------------------|
77. | 53 1995q1 .0072 | 12
78. | 53 1995q2 .0072 | 12
79. | 53 1995q3 .0072 | 12
80. | 53 1995q4 .0072 | 12
81. | 53 1996q1 .0072 | 12
|------------------------------|
82. | 53 1996q2 .0072 | 12
83. | 53 1996q3 .0072 | 12
84. | 53 1996q4 .0072 | 12
85. | 53 1997q1 .0071 | 4
86. | 53 1997q2 .0071 | 4
|------------------------------|
87. | 53 1997q3 .0071 | 4
88. | 53 1997q4 .0071 | 4
89. | 53 1998q1 . | 2
90. | 53 1998q2 . | 2
91. | 53 1998q3 .0067 | 4
|------------------------------|
92. | 53 1998q4 .0067 | 4
93. | 53 1999q1 .0067 | 4
94. | 53 1999q2 .0067 | 4
95. | 53 1999q3 .0076 | 2
96. | 53 1999q4 .0076 | 2
One can note that exp_ratio is constant for few quarters before jumping to a new value (or turn missing). I would like to create a variable that records the length of time a particular value of exp_ratio is relevant; essentially, starting from the top .0091 appears twice, so record 2, then .0084 appears four times, so record 4, etc. In the example above, I manually counted and created the WANTED VARIABLE, which has desired properties.
I'm quite lost as to how to implement this WANTED VARIABLE in Stata, however.. I'd be really grateful for any and all suggestions. Thank you very much in advance!!
Best,
John
Hi, I have a panel data (CRSP mutual fund database), where crsp_fundno identifies a mutual fund and qdatev identifies the quarterly observation time. I am interested in expense ratio (exp_ratio) data point. For example, the following sample lists expense ratio for mutual fund crsp_fundno==53 from 3rd quarter of 1992 to end of 1994
+------------------------------+
| crsp_fundno qdatev exp_ratio | WANTED VARIABLE
|------------------------------|
67. | 53 1992q3 .0091 | 2
68. | 53 1992q4 .0091 | 2
69. | 53 1993q1 .0084 | 4
70. | 53 1993q2 .0084 | 4
71. | 53 1993q3 .0084 | 4
|------------------------------|
72. | 53 1993q4 .0084 | 4
73. | 53 1994q1 .0072 | 12
74. | 53 1994q2 .0072 | 12
75. | 53 1994q3 .0072 | 12
76. | 53 1994q4 .0072 | 12
|------------------------------|
77. | 53 1995q1 .0072 | 12
78. | 53 1995q2 .0072 | 12
79. | 53 1995q3 .0072 | 12
80. | 53 1995q4 .0072 | 12
81. | 53 1996q1 .0072 | 12
|------------------------------|
82. | 53 1996q2 .0072 | 12
83. | 53 1996q3 .0072 | 12
84. | 53 1996q4 .0072 | 12
85. | 53 1997q1 .0071 | 4
86. | 53 1997q2 .0071 | 4
|------------------------------|
87. | 53 1997q3 .0071 | 4
88. | 53 1997q4 .0071 | 4
89. | 53 1998q1 . | 2
90. | 53 1998q2 . | 2
91. | 53 1998q3 .0067 | 4
|------------------------------|
92. | 53 1998q4 .0067 | 4
93. | 53 1999q1 .0067 | 4
94. | 53 1999q2 .0067 | 4
95. | 53 1999q3 .0076 | 2
96. | 53 1999q4 .0076 | 2
One can note that exp_ratio is constant for few quarters before jumping to a new value (or turn missing). I would like to create a variable that records the length of time a particular value of exp_ratio is relevant; essentially, starting from the top .0091 appears twice, so record 2, then .0084 appears four times, so record 4, etc. In the example above, I manually counted and created the WANTED VARIABLE, which has desired properties.
I'm quite lost as to how to implement this WANTED VARIABLE in Stata, however.. I'd be really grateful for any and all suggestions. Thank you very much in advance!!
Best,
John
Comment