Dear All,
I want to create different percentiles (25,50, 75 percentiles accordingly) for my variable (exports) and then create a new dummy variable if my variable exceeds these percentiles. I did the following and it works, however I would like to do the same with using loops and therefore not bother to have many command lines. Here is my codes which I would like to incorporate in a loop.
and so on...
I would appreciate if you can help me to do the same with using loops and therefore be more efficient in coding. Many thanks
I want to create different percentiles (25,50, 75 percentiles accordingly) for my variable (exports) and then create a new dummy variable if my variable exceeds these percentiles. I did the following and it works, however I would like to do the same with using loops and therefore not bother to have many command lines. Here is my codes which I would like to incorporate in a loop.
Code:
egen p25 = pctile( exports ), p(25) gen above25=1 if exports>=p25 replace above25=0 if exports<p25 egen p50 = pctile( exports ), p(50) gen above50=1 if exports>=p50 replace above50=0 if exports<p50
I would appreciate if you can help me to do the same with using loops and therefore be more efficient in coding. Many thanks
Comment