Hi,
I fear I have a quite easy to solve problem but couldn't find a way to do so yet.
Example data:
The variable Deal_No represents an ID that identifies a merger with the Acquirer being the bidding company and it's specific return at the end of a given month. Think of the beginning_end variable as one that indicates a starting and end point for each Deal_No. So each group of Deal_No has exact two entries with the value 1 in the beginning_end variable; the first "1" indicating the starting point and the second "1" the ending point. I am only interested in the observations that fall between these starting and end points (i.e., between the first and second "1" in each group) in terms of time by Deal. Specifically, I would like to replace the missing values that fall between the start and end point of a deal with "1" and generate a variable that counts the number of observations with a "1".
Ultimately, the final result should look like this:
Any help is much appreciated
I fear I have a quite easy to solve problem but couldn't find a way to do so yet.
Example data:
Code:
* Example generated by -dataex-. For more info, type help dataex clear input int Deal_No str8 Acquirer str7 date float return byte beginning_end 123 "ABC Corp" "01/2000" .004 . 123 "ABC Corp" "02/2000" -.05 . 123 "ABC Corp" "03/2000" .011 1 123 "ABC Corp" "04/2000" .011 . 123 "ABC Corp" "05/2000" -.012 . 123 "ABC Corp" "06/2000" -.05 1 123 "ABC Corp" "07/2000" .004 . 321 "DEF Inc" "01/2000" .004 . 321 "DEF Inc" "02/2000" -.05 1 321 "DEF Inc" "03/2000" .011 . 321 "DEF Inc" "04/2000" .011 . 321 "DEF Inc" "05/2000" -.012 . 321 "DEF Inc" "06/2000" -.05 1 321 "DEF Inc" "07/2000" .95 . 321 "DEF Inc" "08/2000" .0032 . 321 "DEF Inc" "09/2000" .0523 . end
Ultimately, the final result should look like this:
Code:
* Example generated by -dataex-. For more info, type help dataex clear input int Deal_No str8 Acquirer str7 date float return byte beginning_end float counter 123 "ABC Corp" "01/2000" .004 . . 123 "ABC Corp" "02/2000" -.05 . . 123 "ABC Corp" "03/2000" .011 1 4 123 "ABC Corp" "04/2000" .011 1 4 123 "ABC Corp" "05/2000" -.012 1 4 123 "ABC Corp" "06/2000" -.05 1 4 123 "ABC Corp" "07/2000" .004 . . 321 "DEF Inc" "01/2000" .004 . . 321 "DEF Inc" "02/2000" -.05 1 5 321 "DEF Inc" "03/2000" .011 1 5 321 "DEF Inc" "04/2000" .011 1 5 321 "DEF Inc" "05/2000" -.012 1 5 321 "DEF Inc" "06/2000" -.05 1 5 321 "DEF Inc" "07/2000" .95 . . 321 "DEF Inc" "08/2000" .0032 . . 321 "DEF Inc" "09/2000" .0523 . . end

Comment