Hi,
This is my first post, so if I accidentally missed any posting rules, please let me know
I have 4 variables as below (avg_se, se_rank, j_order, j_rank_ln). I want to generate a new variable j2, which is:
- If se_rank is the highest, assign j2 the value of j_rank_ln with the lowest j_order.
- If se_rank is the second highest, assign j2 the value of j_rank_ln with the second lowest j_order.
- So on and so forth.
For example, se_rank=3, my new variabel j2 should be 3.02
I tried to do:
But I just got stuck, becuase I don't know how to express second highest, second-lowest, third-highest, etc.
May you give me a lead of how to deal with this?
Thank you!
My data looks like:
This is my first post, so if I accidentally missed any posting rules, please let me know
I have 4 variables as below (avg_se, se_rank, j_order, j_rank_ln). I want to generate a new variable j2, which is:
- If se_rank is the highest, assign j2 the value of j_rank_ln with the lowest j_order.
- If se_rank is the second highest, assign j2 the value of j_rank_ln with the second lowest j_order.
- So on and so forth.
For example, se_rank=3, my new variabel j2 should be 3.02
I tried to do:
Code:
gen j2 =. qui forval i=1/`r(max)' { replace j2= j_rank_ln[`i'] if se_rank }
May you give me a lead of how to deal with this?
Thank you!
My data looks like:
Code:
input float( se_rank j_order j_rank_ln) 1 1 2.01 1 1 2.01 1 1 2.01 1 1 2.01 1 1 2.01 2 2 3.02 2 2 3.02 2 2 3.02 2 2 3.02 4 3 6.01 4 3 6.01 4 3 6.01 4 3 6.01 4 3 6.01 4 3 6.01 3 4 9.15 3 4 9.15 3 4 9.15 3 4 9.15 3 4 9.15 end
Comment