Good evening,
I'm working with a panel data set consisting of firm-year observations. This data set includes a dummy variable called "acquisition" that equals 1 if the firm made an acquisition during the current year and 0 otherwise. Now, I'd like to construct a new dummy variable that captures prior acquisition experience. More specifically, I'd like for this new variable to equal 1 if the acquisition dummy for this firm equals 1 in any prior year and 0 otherwise. Unfortunately, I'm having trouble figuring out the appropriate code. I thought it would be easiest to first create a count variable that reveals the number of prior years with merger activity and then construct a dummy variable equal to 1 any time the count variable carries a non-zero value. However, I can't seem to get the count variable to work.
Does anyone have any advice? For simplicity, you can just assume that the data set consists of 3 variables: id, year, and acquisition (a dummy variable).
Thank you!
Aimee
One way (assuming your data set is sorted by FIRM YEAR):
data want;
set have;
by firm;
retain prior_acquisition;
if first.firm then prior_acquisition = 0;
output;
prior_acquisition = max(prior_acquisition, acquisition);
run;
One way (assuming your data set is sorted by FIRM YEAR):
data want;
set have;
by firm;
retain prior_acquisition;
if first.firm then prior_acquisition = 0;
output;
prior_acquisition = max(prior_acquisition, acquisition);
run;
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.