Hello,
I'm facing a challenge with a variable transformation. I've transformed a variable into percentiles, which has made all the numbers positive. Consequently, I've lost track of whether each value was an increase or a decrease. What I'm trying to achieve is to create a vertical line in my graph between positive and negative values of the variable of interest (prior to the transformation into percentiles). To accomplish this, I need to find the percentile that corresponds to 0 in the distribution of my variable.
In this code, I'm generating percentiles for each observation. What I'm looking to do is create a new local variable, let's call it zero_xvar'_change1', which should be equal to the percentile value of xvar'_change1'` when it equals 0.
Additionally, I'm curious if there's an alternative method to directly set the demarcation line in the graph using percentiles on the x-axis.
Thank you for your assistance!
I'm facing a challenge with a variable transformation. I've transformed a variable into percentiles, which has made all the numbers positive. Consequently, I've lost track of whether each value was an increase or a decrease. What I'm trying to achieve is to create a vertical line in my graph between positive and negative values of the variable of interest (prior to the transformation into percentiles). To accomplish this, I need to find the percentile that corresponds to 0 in the distribution of my variable.
Code:
sort `xvar'_`change1' qui egen `xvar'_`change1'_cdf = xtile(`xvar'_`change1'), nq(100) qui replace `xvar'_`change1'_cdf = round(`xvar'_`change1'_cdf)
In this code, I'm generating percentiles for each observation. What I'm looking to do is create a new local variable, let's call it zero_xvar'_change1', which should be equal to the percentile value of xvar'_change1'` when it equals 0.
Additionally, I'm curious if there's an alternative method to directly set the demarcation line in the graph using percentiles on the x-axis.
Thank you for your assistance!
Comment