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
looping over multiple files - there are new variables in some filesDear stata members, I am trying to loop over multiple files (rounds) of data. In the first two roun…
staet problem with maximum length of observationI am using Stata 15.1 on Windows 10. stset gives a too low maximum observation time (16.949 years an…
"mean" command with factor variables in StataDear all, I wonder if any one knows if there is an alternative command that can do the same things a…
Quadratic Growth ModelDear Stata experts, I'm handling with a longitudinal data from a twin study and want to investigate…
Running Mann-Whitney test on averages over 20 periods for a repeated experiment Dear all, I am running Mann-Whitney tests on data from 6 different treatments of an economic exper…
Subscribe to:
Post Comments (Atom)
0 Response to Numbering a variable based on previous observation
Post a Comment