Dear all
I want to make a moderating variable called M&A active and give firms (identified by variable gvkey) a 0 in fyears (variable of fiscal year ) before acquisition or in every year between 1997-2015 if they never had an M&A. And a 1 in year from M&A and years AFTER FIRST M&A. Now, firms that never had an M&A already have a 0 in variable maactive but the firms that had an m&a only got a 1 in the years of the ma and not in the years after or in-between them. In the screenshot below you can see an example of ABBOT LABORATORIES.
I tried the following code: by gvkey (fyear), sort: replace maactive = maactive [_n-1] if maactive = 1
because I thought that it would give firms based on gvkey a 1 in the variable maactive if the previous observation of their gvkey is a 1. But I did not work out. I received error code r(101) weights not allowed. Could someone help me with this?
Array
Related Posts with Numbering a variable based on previous observation
Dropping missing observations under several conditionsHej Statalist, I have a problem with dropping some observations. I analyse a trade data set and hav…
classified after XT models - invalid subcommand classificationHello, I am using 4 binomial models. Logit, xtlogit re, xtlogit pa, and xtlogit fe. After logit I us…
Regression output does not show all coefficientsHi, I have a quick question: When I enter the following code for a regression with 1 independent v…
Manipulate x-axis in twoway graph with dates Hi Stata users, I want to make a twoway bar graph that plots a number (on the y axis) against a dat…
merge on most recent fiscal year endHi Statalist, I am trying to merge an annual dataset with a quarterly dataset based on most recent …
Subscribe to:
Post Comments (Atom)
0 Response to Numbering a variable based on previous observation
Post a Comment