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
Assigning colors to box plot with stratificationDear Forum, I would like to box plot sCD163 over HIV status (positive vs. negative) (i) stratified …
Replicate xi: results using xtregHello everyone. Hope you all are well. I am looking at this regression and dataset which was used …
ivregress for binary variablesHi All. I am analyzing data from a trial looking at the impact of treatment on prognosis (i.e. dead…
Help me with fixed effect model please! Many thanksHello I am planning to run a fixed effect model in stata. However I would like to discuss here 1) wh…
combining and/or expressionsGood afternoon, I have a panel dataset with observations from different countries and different year…
Subscribe to:
Post Comments (Atom)
0 Response to gen with differences between observations
Post a Comment