/* This file was created by Molly Fifer */ clear set more off set mem 500m program drop _all use "P:\Projects\Other\PATS Analysis\PATS\Public\wide_public_rdd" /* Identify those in chronic pain as those who give a pain rating of greater than 3 for all 3 episodes selected. Compare time use among those in chronic pain and the rest of the sample. */ /* Drop weekend days from the sample */ drop if diaryday=="Saturday" | diaryday=="Sunday" keep if pain>3 & pain<=6 collapse (count) age, by(idnum) keep if age==3 gen chronic=1 sort idnum drop age save chronic, replace use "P:\Projects\Other\PATS Analysis\PATS\Public\long_public_rdd", clear sort idnum merge idnum using chronic tab _merge drop _merge replace chronic=0 if chronic==. drop if actcode1_tier1==1 & actcode1_tier2==1 collapse (sum) duration, by(idnum chronic actcode1_tier1 actcode1_tier2 actcode1_tier3 pwt) sort idnum by idnum: egen totdur=total(duration) rename actcode1_tier1 aactcode1_tier1 rename actcode1_tier2 aactcode1_tier2 rename actcode1_tier3 aactcode1_tier3 gen otherpersonal=0 replace otherpersonal=duration if aactcode1_tier1==1&!(aactcode1_tier2==1) gen housework=0 replace housework=duration if aactcode1_tier1==2&aactcode1_tier2==1 gen fooddrink=0 replace fooddrink=duration if aactcode1_tier1==2&aactcode1_tier2==2 gen lawngarden=0 replace lawngarden=duration if aactcode1_tier1==2&aactcode1_tier2==5 gen hhmgt=0 replace hhmgt=duration if aactcode1_tier1==2&aactcode1_tier2==9 gen childcare=0 replace childcare=duration if (aactcode1_tier1==3|aactcode1_tier1==4)&(aactcode1_tier2==1|aactcode1_tier2==2|aactcode1_tier2==3) gen othercare=0 replace othercare=duration if (aactcode1_tier1==3|aactcode1_tier1==4)&!(aactcode1_tier2==1|aactcode1_tier2==2|aactcode1_tier2==3) gen working=0 replace working=duration if aactcode1_tier1==5&aactcode1_tier2==1 gen education=0 replace education=duration if aactcode1_tier1==6 gen consumerpurch=0 replace consumerpurch=duration if aactcode1_tier1==7 gen medicalcare=0 replace medicalcare=duration if aactcode1_tier1==8&aactcode1_tier2==4 gen eatingdrinking=0 replace eatingdrinking=duration if aactcode1_tier1==11 gen socializing=0 replace socializing=duration if aactcode1_tier1==12&(aactcode1_tier2==1|aactcode1_tier2==2) gen relaxleisure=0 replace relaxleisure=duration if aactcode1_tier1==12&aactcode1_tier2==3&aactcode1_tier3~=3&aactcode1_tier3~=4 gen tv=0 replace tv=duration if aactcode1_tier1==12&aactcode1_tier2==3&(aactcode1_tier3==3|aactcode1_tier3==4) gen sportsexerec=0 replace sportsexerec=duration if aactcode1_tier1==13 gen relig=0 replace relig=duration if aactcode1_tier1==14 gen volunteer=0 replace volunteer=duration if aactcode1_tier1==15 gen phone=0 replace phone=duration if aactcode1_tier1==16 gen travel=0 replace travel=duration if aactcode1_tier1==17|aactcode1_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 chronic 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 avesharenon=. gen avesharechron=. gen se=. program drop _all program table replace actshare=`2'/totdur reg actshare chronic [aw=pwt] matrix b=e(b) replace avesharenon=b[1,2] in `1' replace avesharechron=b[1,1]+b[1,2] in `1' matrix V=e(V) replace se=sqrt(V[1,1]) in `1' replace actcompare="`2'" in `1' matrix drop _all 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 avesharenon avesharechron actcompare se keep if avesharenon~=. replace actcompare="food&drink" if actcompare=="fooddrink" outsheet using "P:\Projects\Other\PATS Analysis\PATS\Public\chronicact.raw", replace