/* This file was created by Molly Fifer */ clear set mem 50m set more off program drop _all use "P:\Projects\Other\PATS Analysis\PATS\Public\wide_public_rdd" /* This file calculates by activity and gender: i. % of episodes with pain>0 ii. % of episodes with pain>3 iii. Average pain intensity (including zeros) iv. Average happy rating v. % of day spent in activity (by person, % of waking day in each activity; average over all people) */ gen greater0=. replace greater0=0 if pain==0 replace greater0=1 if pain>0 & pain<=6 label var greater0 "pain>0" gen greater3=. replace greater3=0 if pain<=3 replace greater3=1 if pain>3 & pain<=6 label var greater3 "pain>3" save pain, replace /* Sample weight */ generate actcompare = "" program table di="MEN" sum `3' [aw=pwt] if sex==1 & `4' replace men`3'=r(mean) in `1' replace mobs`3'=r(N) in `1' di="WOMEN" sum `3' [aw=pwt] if sex==2 & `4' replace wom`3'=r(mean) in `1' replace fobs`3'=r(N) in `1' di="ALL" sum `3' [aw=pwt] if `4' replace all`3'=r(mean) in `1' replace allobs`3'=r(N) in `1' replace actcompare="`2'" in `1' end program pain gen men`1'=. gen wom`1'=. gen all`1'=. gen mobs`1'=. gen fobs`1'=. gen allobs`1'=. table 1 otherpersonal `1' actcode1_tier1==1&!(actcode1_tier2==1) /*Personal care, excluding sleeping*/ table 2 housework `1' actcode1_tier1==2&actcode1_tier2==1 /*Housework*/ table 3 food&drink `1' actcode1_tier1==2&actcode1_tier2==2 /*Food & drink prep, presentation, and clean-up*/ table 4 lawngarden `1' actcode1_tier1==2&actcode1_tier2==5 /*Lawn, garden, and houseplants*/ table 5 hhmgt `1' actcode1_tier1==2&actcode1_tier2==9 /*Household management*/ table 6 childcare `1' (actcode1_tier1==3|actcode1_tier1==4)&(actcode1_tier2==1|actcode1_tier2==2|actcode1_tier2==3) /*Caring for/activities related to HH and nonHH children*/ table 7 othercare `1' (actcode1_tier1==3|actcode1_tier1==4)&!(actcode1_tier2==1|actcode1_tier2==2|actcode1_tier2==3) /*All other care*/ table 8 working `1' actcode1_tier1==5&actcode1_tier2==1 /*Working*/ table 9 education `1' actcode1_tier1==6 /*Education*/ table 10 consumerpurch `1' actcode1_tier1==7 /*Consumer purchases*/ table 11 medicalcare `1' actcode1_tier1==8&actcode1_tier2==4 /*Medical and care services*/ table 12 eatingdrinking `1' actcode1_tier1==11 /*Eating and drinking*/ table 13 socializing `1' actcode1_tier1==12&(actcode1_tier2==1|actcode1_tier2==2) /*Socializing*/ table 14 relaxleisure `1' actcode1_tier1==12&actcode1_tier2==3&actcode1_tier3~=3&actcode1_tier3~=4 /*Relaxing and leisure, non-tv*/ table 15 tv `1' actcode1_tier1==12&actcode1_tier2==3&(actcode1_tier3==3|actcode1_tier3==4) /*TV*/ table 16 sportsexerec `1' actcode1_tier1==13 /*Sports, exercise, and recreation -- total*/ table 17 relig `1' actcode1_tier1==14 /*Religious*/ table 18 volunteer `1' actcode1_tier1==15 /*Volunteering*/ table 19 phone `1' actcode1_tier1==16 /*Telephone*/ table 20 travel `1' actcode1_tier1==17|actcode1_tier1==18 /*Travel*/ table 21 all `1' actcode1_tier1>=0 end pain greater0 pain greater3 keep actcompare men* wom* all* mobs* fobs* allobs* keep if mengreater0~=. gen order=_n sort actcompare save painbyact, replace program drop _all use pain, clear generate actcompare = "" program table di="MEN" sum `3' if sex==1 & `3'<= 6 & `4' [aw=pwt] replace men`3'=r(mean) in `1' replace mobs`3'=r(N) in `1' di="WOMEN" sum `3' if sex==2 & `3'<= 6 & `4' [aw=pwt] replace wom`3'=r(mean) in `1' replace fobs`3'=r(N) in `1' di="ALL" sum `3' if `3'<= 6 & `4' [aw=pwt] replace all`3'=r(mean) in `1' replace allobs`3'=r(N) in `1' replace actcompare="`2'" in `1' end program pain gen men`1'=. gen wom`1'=. gen all`1'=. gen mobs`1'=. gen fobs`1'=. gen allobs`1'=. table 1 otherpersonal `1' actcode1_tier1==1&!(actcode1_tier2==1) /*Personal care, excluding sleeping*/ table 2 housework `1' actcode1_tier1==2&actcode1_tier2==1 /*Housework*/ table 3 food&drink `1' actcode1_tier1==2&actcode1_tier2==2 /*Food & drink prep, presentation, and clean-up*/ table 4 lawngarden `1' actcode1_tier1==2&actcode1_tier2==5 /*Lawn, garden, and houseplants*/ table 5 hhmgt `1' actcode1_tier1==2&actcode1_tier2==9 /*Household management*/ table 6 childcare `1' (actcode1_tier1==3|actcode1_tier1==4)&(actcode1_tier2==1|actcode1_tier2==2|actcode1_tier2==3) /*Caring for/activities related to HH and nonHH children*/ table 7 othercare `1' (actcode1_tier1==3|actcode1_tier1==4)&!(actcode1_tier2==1|actcode1_tier2==2|actcode1_tier2==3) /*All other care*/ table 8 working `1' actcode1_tier1==5&actcode1_tier2==1 /*Working*/ table 9 education `1' actcode1_tier1==6 /*Education*/ table 10 consumerpurch `1' actcode1_tier1==7 /*Consumer purchases*/ table 11 medicalcare `1' actcode1_tier1==8&actcode1_tier2==4 /*Medical and care services*/ table 12 eatingdrinking `1' actcode1_tier1==11 /*Eating and drinking*/ table 13 socializing `1' actcode1_tier1==12&(actcode1_tier2==1|actcode1_tier2==2) /*Socializing*/ table 14 relaxleisure `1' actcode1_tier1==12&actcode1_tier2==3&actcode1_tier3~=3&actcode1_tier3~=4 /*Relaxing and leisure, non-tv*/ table 15 tv `1' actcode1_tier1==12&actcode1_tier2==3&(actcode1_tier3==3|actcode1_tier3==4) /*TV*/ table 16 sportsexerec `1' actcode1_tier1==13 /*Sports, exercise, and recreation -- total*/ table 17 relig `1' actcode1_tier1==14 /*Religious*/ table 18 volunteer `1' actcode1_tier1==15 /*Volunteering*/ table 19 phone `1' actcode1_tier1==16 /*Telephone*/ table 20 travel `1' actcode1_tier1==17|actcode1_tier1==18 /*Travel*/ table 21 all `1' actcode1_tier1>=0 end pain pain pain happy keep actcompare men* wom* all* mobs* fobs* allobs* keep if menpain~=. sort actcompare save merge, replace use painbyact, clear merge actcompare using merge tab _merge drop _merge sort actcompare save painbyact, replace program drop _all use "P:\Projects\Other\PATS Analysis\PATS\Public\long_public_rdd", clear drop if actcode1_tier1==1 & actcode1_tier2==1 collapse (sum) duration, by(idnum actcode1_tier1 actcode1_tier2 actcode1_tier3 pwt) sort idnum by idnum: egen totdur=total(duration) gen otherpersonal=0 replace otherpersonal=duration if actcode1_tier1==1&!(actcode1_tier2==1) gen housework=0 replace housework=duration if actcode1_tier1==2&actcode1_tier2==1 gen fooddrink=0 replace fooddrink=duration if actcode1_tier1==2&actcode1_tier2==2 gen lawngarden=0 replace lawngarden=duration if actcode1_tier1==2&actcode1_tier2==5 gen hhmgt=0 replace hhmgt=duration if actcode1_tier1==2&actcode1_tier2==9 gen childcare=0 replace childcare=duration if (actcode1_tier1==3|actcode1_tier1==4)&(actcode1_tier2==1|actcode1_tier2==2|actcode1_tier2==3) gen othercare=0 replace othercare=duration if (actcode1_tier1==3|actcode1_tier1==4)&!(actcode1_tier2==1|actcode1_tier2==2|actcode1_tier2==3) gen working=0 replace working=duration if actcode1_tier1==5&actcode1_tier2==1 gen education=0 replace education=duration if actcode1_tier1==6 gen consumerpurch=0 replace consumerpurch=duration if actcode1_tier1==7 gen medicalcare=0 replace medicalcare=duration if actcode1_tier1==8&actcode1_tier2==4 gen eatingdrinking=0 replace eatingdrinking=duration if actcode1_tier1==11 gen socializing=0 replace socializing=duration if actcode1_tier1==12&(actcode1_tier2==1|actcode1_tier2==2) gen relaxleisure=0 replace relaxleisure=duration if actcode1_tier1==12&actcode1_tier2==3&actcode1_tier3~=3&actcode1_tier3~=4 gen tv=0 replace tv=duration if actcode1_tier1==12&actcode1_tier2==3&(actcode1_tier3==3|actcode1_tier3==4) gen sportsexerec=0 replace sportsexerec=duration if actcode1_tier1==13 gen relig=0 replace relig=duration if actcode1_tier1==14 gen volunteer=0 replace volunteer=duration if actcode1_tier1==15 gen phone=0 replace phone=duration if actcode1_tier1==16 gen travel=0 replace travel=duration if actcode1_tier1==17|actcode1_tier1==18 save act, replace collapse (sum) otherpersonal housework fooddrink lawngarden hhmgt childcare othercare working education consumerpurch medicalcare eatingdrinking socializing relaxleisure tv sportsexerec relig volunteer phone travel, by(idnum) sort idnum save merge, replace use act, clear keep idnum pwt totdur sort idnum by idnum: gen n=_n keep if n==1 drop n sort idnum merge idnum using merge tab _merge drop _merge save act2, replace generate actcompare = "" gen actshare=. gen aveshare=. program table replace actshare=`2'/totdur sum actshare [aw=pwt] replace aveshare=r(mean) in `1' replace actcompare="`2'" in `1' end table 1 otherpersonal table 2 housework table 3 fooddrink table 4 lawngarden table 5 hhmgt table 6 childcare table 7 othercare table 8 working table 9 education table 10 consumerpurch table 11 medicalcare table 12 eatingdrinking table 13 socializing table 14 relaxleisure table 15 tv table 16 sportsexerec table 17 relig table 18 volunteer table 19 phone table 20 travel keep aveshare actcompare keep if aveshare~=. replace actcompare="food&drink" if actcompare=="fooddrink" sort actcompare save merge, replace use painbyact, clear sort actcompare merge actcompare using merge tab _merge drop _merge sort actcompare save painbyact, replace /* Doing chi-squared tests on the differences */ use pain, clear gen female=. replace female=0 if sex==1 replace female=1 if sex==2 program drop _all generate actcompare = "" program table reg `3' female [aw=pwt] if `4', cluster(idnum) test female replace chi`3'=r(p) in `1' replace actcompare="`2'" in `1' end program pain gen chi`1'=. table 1 otherpersonal `1' actcode1_tier1==1&!(actcode1_tier2==1) /*Personal care, excluding sleeping*/ table 2 housework `1' actcode1_tier1==2&actcode1_tier2==1 /*Housework*/ table 3 food&drink `1' actcode1_tier1==2&actcode1_tier2==2 /*Food & drink prep, presentation, and clean-up*/ table 4 lawngarden `1' actcode1_tier1==2&actcode1_tier2==5 /*Lawn, garden, and houseplants*/ table 5 hhmgt `1' actcode1_tier1==2&actcode1_tier2==9 /*Household management*/ table 6 childcare `1' (actcode1_tier1==3|actcode1_tier1==4)&(actcode1_tier2==1|actcode1_tier2==2|actcode1_tier2==3) /*Caring for/activities related to HH and nonHH children*/ table 7 othercare `1' (actcode1_tier1==3|actcode1_tier1==4)&!(actcode1_tier2==1|actcode1_tier2==2|actcode1_tier2==3) /*All other care*/ table 8 working `1' actcode1_tier1==5&actcode1_tier2==1 /*Working*/ table 9 education `1' actcode1_tier1==6 /*Education*/ table 10 consumerpurch `1' actcode1_tier1==7 /*Consumer purchases*/ table 11 medicalcare `1' actcode1_tier1==8&actcode1_tier2==4 /*Medical and care services*/ table 12 eatingdrinking `1' actcode1_tier1==11 /*Eating and drinking*/ table 13 socializing `1' actcode1_tier1==12&(actcode1_tier2==1|actcode1_tier2==2) /*Socializing*/ table 14 relaxleisure `1' actcode1_tier1==12&actcode1_tier2==3&actcode1_tier3~=3&actcode1_tier3~=4 /*Relaxing and leisure, non-tv*/ table 15 tv `1' actcode1_tier1==12&actcode1_tier2==3&(actcode1_tier3==3|actcode1_tier3==4) /*TV*/ table 16 sportsexerec `1' actcode1_tier1==13 /*Sports, exercise, and recreation -- total*/ table 17 relig `1' actcode1_tier1==14 /*Religious*/ table 18 volunteer `1' actcode1_tier1==15 /*Volunteering*/ table 19 phone `1' actcode1_tier1==16 /*Telephone*/ table 20 travel `1' actcode1_tier1==17|actcode1_tier1==18 /*Travel*/ table 21 all `1' actcode1_tier1>=0 end pain greater0 pain greater3 pain pain pain happy keep actcompare chi* sort actcompare keep if chipain~=. save merge, replace use painbyact, clear sort actcompare merge actcompare using merge tab _merge drop _merge sort order drop order save painbyact, replace outsheet using "P:\Projects\Other\PATS Analysis\PATS\Public\painbyact_pwt.raw", replace