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
Complex dummy variableHi STATLIST, Merry Christmas to those celebrating it and happy new Year. I have a question about th…
De trending// De seasonalising data - find weekly meanHiya, for my project i have daily stock market data (returns and volatility) and daily weather (clo…
Cox regression with enourmous Hazard Ratio (logarithmic)Dear forum, I have encountered a problem in that for my Cox regression my output gives enourmous Ha…
Simple Time Series RegressionHello everyone, I have a fairly simple question and hope you guys can help me out. I already studie…
IDs in different categories : how to count ?Dear statalist members, I have a sample of about 1 million people (id) with one or more records in …
Subscribe to:
Post Comments (Atom)
0 Response to gen with differences between observations
Post a Comment