Hello everyone
I'm not so sure that I'll describe the issue perfectly, but here it comes
I'm having some troubles while trying to code something wich i think is similar to the "lookup" function in excel.
The data panel below is quiet similar to the one i'm working on:
'goal_aprov' is where i'm trying to use some egen argument in order to return the value I want. I need it to return me in 'rel_p' row, the nearst value of 'aprov_4ef' wich matches with the variable 'p'.
This is what the first row should look like after the code i'm looking for:
The reason it happend is because 'rel_p' is pretty near to 'p' in the 15th row, so it returned the aprov_4ef value of the same row.
What should I do to complete 'goal_aprov'?
I don't know if it helps, but this is the equation of rel_p:
rel_p = (3/2)*p^3 - (11/4)*p^2 + 2p + (1/4)
I'm not so sure that I'll describe the issue perfectly, but here it comes
I'm having some troubles while trying to code something wich i think is similar to the "lookup" function in excel.
The data panel below is quiet similar to the one i'm working on:
cod_univ | year | aprov_4ef | reg_4ef | UF | p | rel_p | goal_aprov |
1 | 2014 | 73.2 | 278 | 11 | 0 | .25 | |
2 | 2014 | 75.6 | 129 | 11 | .02 | .288912 | |
3 | 2014 | 77.1 | 520 | 11 | .039 | .3239062 | |
4 | 2014 | 77.4 | 411 | 11 | .059 | .3587353 | |
5 | 2014 | 77.7 | 257 | 11 | .078 | .3899808 | |
6 | 2014 | 80.7 | 405 | 11 | .098 | .4210008 | |
7 | 2014 | 81 | 320 | 11 | .118 | .4501736 | |
8 | 2014 | 81.5 | 282 | 11 | .137 | .4762423 | |
9 | 2014 | 82.6 | 704 | 11 | .157 | .5020201 | |
10 | 2014 | 83 | 321 | 11 | .176 | .5249937 | |
11 | 2014 | 83.3 | 170 | 11 | .196 | .5476503 | |
12 | 2014 | 83.9 | 800 | 11 | .216 | .5688125 | |
13 | 2014 | 84 | 763 | 11 | .235 | .5875981 | |
14 | 2014 | 85.1 | 407 | 11 | .275 | .6232266 | |
15 | 2014 | 85.1 | 1525 | 11 | .255 | .6060533 | |
16 | 2014 | 85.4 | 199 | 11 | .294 | .6384193 | |
17 | 2014 | 85.8 | 1983 | 11 | .314 | .6532997 |
'goal_aprov' is where i'm trying to use some egen argument in order to return the value I want. I need it to return me in 'rel_p' row, the nearst value of 'aprov_4ef' wich matches with the variable 'p'.
This is what the first row should look like after the code i'm looking for:
cod_univ | year | aprov_4ef | reg_4ef | UF | p | rel_p | goal_aprov |
1 | 2014 | 73.2 | 278 | 11 | 0 | .25 | 85.1 |
The reason it happend is because 'rel_p' is pretty near to 'p' in the 15th row, so it returned the aprov_4ef value of the same row.
What should I do to complete 'goal_aprov'?
I don't know if it helps, but this is the equation of rel_p:
rel_p = (3/2)*p^3 - (11/4)*p^2 + 2p + (1/4)
Comment