Dear all,
I have the following dataset.
I am trying to create a variable that generates 1 when the % of ownership of a firm increases and 0 for the rest (that is % of ownership remains the same or decrease).
I tried the following code which kind of work but it indicates the number of change in the % of ownership (ie. 1,2,3 and so on) regardless if it increases or decreases.
by permno year (ownership), sort: gen increase = sum(ownership~=ownership[_n-1] & _n~=1)
permno year ownership increase
05236 2015 36.3 1
05236 2015 36.3 1
05236 2015 36.3 1
05236 2015 36.3 1
05236 2015 37 2
05236 2015 37 2
05236 2015 37 2
05236 2015 37 2
05236 2015 37 2
05236 2015 37 2
05236 2015 38 3
05236 2015 38 3
Related Posts with gen with differences between observations
Two different colours when using histogram, byHi all, I am trying to generate two histograms with the following code. histogram lines, discrete …
Rounding off long decimals after importing from excelDear Statalist forum, I am encountering an issue that seems to be trivial, but so far I have not fo…
Issues with Time-Invariant Variables when using Stack Command in panel regressionHi everyone - I'm trying to use the stack command to compare the effects of the same independent va…
gsem: Same code, no longer workingHello, I am using gsem in Stata 15 for an LCA, and although I have been using Stata for some time, …
Adding dots to the top of a line in graph twowayHi all, I am trying to put dots on certain months similar to the graph below. Do you know how to do …
Subscribe to:
Post Comments (Atom)
0 Response to gen with differences between observations
Post a Comment