I have 5 variables in my dataset namely, household id, wealth rank, and household ids of three friends for the household being interviewed.
Is there a way I can create 3 separate variables one for each friend that simply replaces the household id with the wealth rank of that household. For instance, HH 1 is friends with hh3, hh4 and hh6. I'd like to have 3 columns with wrank values 700, 100 and 300.
I feel like this is something very simple but I just can't get my head around it. Any help in this regard will be much appreciated.
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input float(hh wrank fr1 fr2 fr3) 1 500 3 4 6 2 600 1 6 . 3 700 4 . . 4 100 5 2 . 5 200 1 . . 6 300 4 5 1 end
0 Response to Replacing column values with values of another variable by household id
Post a Comment