sortorder | name | cum_pct | delta |
1 | Bob | 0.2 | 0.4 |
2 | Alice | 0.5 | 0.1 |
3 | Eugene | 0.58 | 0.02 |
4 | Theresa | 0.7 | 0.1 |
5 | Thomas | 1 | 0.3 |
Hello,
I have a cumulative percentage variable like the one below, and I want to figure out which observation is the closest to an arbitrary threshold, say 60%. I used the following line:
Code:
bysort sortorder: gen delta = min(abs(cum_pct - 0.6), cum_pct)
Thanks!
Comment