I have the following data set in which I have successfully created a new variable wvsrLAD that takes the value of the most recently available value (from variables v26 to mostpe~p, v26 being the most recently available and mostpe~p being the oldest).
Code:
+-------------------------------------------------------------------------------------------------------------------+ countryname mostpe~p mostp~19 v22 v23 v24 mostp~20 v26 wvsrLAD 1.Afghanistan . . . . . . . . 2.Albania . . . .2432432 .232 . . .232 3.Algeria . . . . .1076443 . .1792863 .1792863 4.Argentina . .2700733 .2235529 .1708436 .1501535 .1740575 .1935307 .1935307 5.Armenia . . . .235 . . .1091358 .1091358 6.Australia . .4781494 . .3944921 . .461379 .5181401 .5181401 7.Austria . . . . . . . . 8.Azerbaijan . . . .1943057 . . .1479329 .1479329 9.Bahrain . . . . . . .335 .335 10.Bangladesh . . . .2045902 .2326667 . . .2326667
Code:
replace wvsrLAD = mostpeoplecanbetrustedwvsround20 if missing(v26) replace wvsrLAD = v24 if missing(v26) & missing(mostpeoplecanbetrustedwvsround20) replace wvsrLAD = v23 if missing(v24) & missing(v26) & missing(mostpeoplecanbetrustedwvsround20) replace wvsrLAD = v22 if missing(v23) & missing(v24) & missing(v26) & missing(mostpeoplecanbetrustedwvsround20)
0 Response to Replacing Missing Observations With Older Available Data
Post a Comment