Hello,
I've managed to successfully generate a variable that describes the proportion of people working from home during the pandemic within their occupation, socworkfromhome, using the following command:
bys b10soc3: egen socworkfromhome2016=mean(cw1_workfromhome)
Where b10soc3 is the person's occupational code in 2016.
Now, where I am stuck is that I want to generate a variable socworkfromhome2012 where if socworkfromhome2016=0.5 when b10soc3=111 and socworkfromhome2016=0.5 when b10soc=112 then, I want tsocworkfromhome2012 to equal 0.5 if b9soc3 (2012 occupational code)=111 and equal 0.25 if b9soc3=112 etc. However, I do not know how to do this.
It feels like I'm missing something very simple (although I can't work out how to do it from any online resource) and I'm not sure I have explained myself well, so thank you for any help.
If it helps, my data looks like this:
I've managed to successfully generate a variable that describes the proportion of people working from home during the pandemic within their occupation, socworkfromhome, using the following command:
bys b10soc3: egen socworkfromhome2016=mean(cw1_workfromhome)
Where b10soc3 is the person's occupational code in 2016.
Now, where I am stuck is that I want to generate a variable socworkfromhome2012 where if socworkfromhome2016=0.5 when b10soc3=111 and socworkfromhome2016=0.5 when b10soc=112 then, I want tsocworkfromhome2012 to equal 0.5 if b9soc3 (2012 occupational code)=111 and equal 0.25 if b9soc3=112 etc. However, I do not know how to do this.
It feels like I'm missing something very simple (although I can't work out how to do it from any online resource) and I'm not sure I have explained myself well, so thank you for any help.
If it helps, my data looks like this:
Code:
* Example generated by -dataex-. For more info, type help dataex clear input int(b10soc3 b9soc3) float(cw1_workfromhome socworkfromhome2016) 544 523 0 .0909091 416 411 . .27380952 415 415 0 .313253 353 353 . .365285 813 112 0 .018181818 119 112 0 .09036145 125 245 1 .1737805 247 343 0 .3703704 113 113 1 .3995633 823 123 0 .020833334 415 0 1 .313253 113 113 1 .3995633 113 113 0 .3995633 921 921 0 .07777778 421 421 . .2534722 125 112 0 .1737805 542 112 . .029411765 244 0 .5 .6875 354 353 1 .29672897 413 . 0 .27857143 end

Comment