I need to fill up the missing values for the variable (v1). The variables are {country, v1, v2}
I have sporadic missing values in v1, but v1 and v2 have high correlation, so I can fill up v1 based on the order statistics of v2.
For example, I want to replace v1[1] to v2 if v2_rank == 1
I tried
replace v1 = v2[v2_rank] if v1 == .
replace v1 = v2[_v2_rank] if v1 == .
But it does not work...
I have sporadic missing values in v1, but v1 and v2 have high correlation, so I can fill up v1 based on the order statistics of v2.
For example, I want to replace v1[1] to v2 if v2_rank == 1
I tried
replace v1 = v2[v2_rank] if v1 == .
replace v1 = v2[_v2_rank] if v1 == .
But it does not work...
country | v1 | v2 | v1_rank | v2_rank |
SG | . | 11 | . | 1 |
NL | 10 | 10 | 1 | 2 |
HK | 9 | 9 | 2 | 3 |
GB | 8 | 8 | 3 | 4 |
Comment