/* This file was created by Molly Fifer */ clear set more off program drop _all use "P:\Projects\Other\PATS Analysis\PATS\Public\wide_public_rdd" /* This file calculates: i. % of episodes with pain>0 ii. % of episodes with pain>3 iii. Average pain intensity (including zeros) By different demographic groups: i. Gender ii. Income brackets iii. Age: 10-year brackets currently used in the data iv. Race/ethnicity: Hispanic, White, Black, Asian v. Education: LTHS, HS, some college, college, college plus vi. Marital status vii. Life satisfaction viii. Disability status ix. Self-reported health satisfaction */ replace disabled=0 if disabled==2 replace disabled=. if disabled>=8 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 */ use pain, clear program drop _all generate group="" program table sum `3' [aw=pwt] if `4' & `3'~=. replace mean`3'=r(mean) in `1' replace n`3'=r(N) in `1' replace group="`2'" in `1' end program pain gen mean`1'=. gen n`1'=. table 1 men `1' sex==1 table 2 women `1' sex==2 table 3 hhinclt30 `1' hhinc>=1&hhinc<=3 table 4 hhinc30_49 `1' hhinc>=4&hhinc<=5 table 5 hhinc50_99 `1' hhinc>=6&hhinc<=7 table 6 hhincge100 `1' hhinc>7&hhinc<98 table 7 agelt20 `1' age<20 table 8 age20_29 `1' age>=20&age<30 table 9 age30_39 `1' age>=30&age<40 table 10 age40_49 `1' age>=40&age<50 table 11 age50_59 `1' age>=50&age<60 table 12 age60_69 `1' age>=60&age<70 table 13 age70_79 `1' age>=70&age<80 table 14 age80_89 `1' age>=80&age<90 table 15 age90_99 `1' age>=90&age<100 table 16 age18_24 `1' age>=18&age<=24 table 17 age25_34 `1' age>=25&age<=34 table 18 age35_44 `1' age>=35&age<=44 table 19 age45_54 `1' age>=45&age<=54 table 20 age55_64 `1' age>=55&age<=64 table 21 age65_74 `1' age>=65&age<=74 table 22 agege75 `1' age>=75 table 23 white `1' race_1==1&hispanic!=1&race_2==. table 24 black `1' race_1==2&hispanic!=1&race_2==. table 25 asian `1' race_1==3&hispanic!=1&race_2==. table 26 hispanic `1' hispanic==1 table 27 lths `1' educ<=8 table 28 hsed `1' educ==9 table 29 somecoll `1' educ>9&educ<=12 table 30 colled `1' educ==13 table 31 gtcoll `1' educ>13&educ<98 table 32 married `1' marital==2 table 33 notmarried `1' marital~=2&marital<8 table 34 life_notatall `1' lisat==1 table 35 life_notsat `1' lisat==2 table 36 life_sat `1' lisat==3 table 37 life_verysat `1' lisat==4 table 38 health_notatall `1' hlsat==1 table 39 health_notsat `1' hlsat==2 table 40 health_sat `1' hlsat==3 table 41 health_verysat `1' hlsat==4 table 42 disabled `1' disabled==1 table 43 notdisabled `1' disabled==0 end pain greater0 pain greater3 pain pain keep group mean* n* keep if meangreater0~=. gen order=_n save painbydemo, replace /* Doing chi-squared tests on the differences */ use pain, clear replace pain=. if pain>6 gen male=0 replace male=1 if sex==1 gen female=0 replace female=1 if sex==2 gen hhinclt30=0 replace hhinclt30=1 if hhinc>=1&hhinc<=3 gen hhinc30_49=0 replace hhinc30_49=1 if hhinc>=4&hhinc<=5 gen hhinc50_99=0 replace hhinc50_99=1 if hhinc>=6&hhinc<=7 gen hhincge100=0 replace hhincge100=1 if hhinc>7&hhinc<98 gen agelt20=0 replace agelt20=1 if age<20 gen age20_29=0 replace age20_29=1 if age>=20&age<30 gen age30_39=0 replace age30_39=1 if age>=30&age<40 gen age40_49=0 replace age40_49=1 if age>=40&age<50 gen age50_59=0 replace age50_59=1 if age>=50&age<60 gen age60_69=0 replace age60_69=1 if age>=60&age<70 gen age70_79=0 replace age70_79=1 if age>=70&age<80 gen age80_89=0 replace age80_89=1 if age>=80&age<90 gen age90_99=0 replace age90_99=1 if age>=90&age<100 gen age18_24=0 replace age18_24=1 if age>=18&age<=24 gen age25_34=0 replace age25_34=1 if age>=25&age<=34 gen age35_44=0 replace age35_44=1 if age>=35&age<=44 gen age45_54=0 replace age45_54=1 if age>=45&age<=54 gen age55_64=0 replace age55_64=1 if age>=55&age<=64 gen age65_74=0 replace age65_74=1 if age>=65&age<=74 gen agege75=0 replace agege75=1 if age>=75 gen white=0 replace white=1 if race_1==1&hispanic!=1&race_2==. gen black=0 replace black=1 if race_1==2&hispanic!=1&race_2==. gen asian=0 replace asian=1 if race_1==3&hispanic!=1&race_2==. replace hispanic=0 if hispanic==2 replace hispanic=. if hispanic>1 label drop d4 gen lths=0 replace lths=1 if educ<=8 gen hsed=0 replace hsed=1 if educ==9 gen somecoll=0 replace somecoll=1 if educ>9&educ<=12 gen colled=0 replace colled=1 if educ==13 gen gtcoll=0 replace gtcoll=1 if educ>13&educ<98 gen married=0 replace married=1 if marital==2 gen notmarried=0 replace notmarried=1 if marital~=2 gen life_notatall=0 replace life_notatall=1 if lisat==1 gen life_notsat=0 replace life_notsat=1 if lisat==2 gen life_sat=0 replace life_sat=1 if lisat==3 gen life_verysat=0 replace life_verysat=1 if lisat==4 gen health_notatall=0 replace health_notatall=1 if hlsat==1 gen health_notsat=0 replace health_notsat=1 if hlsat==2 gen health_sat=0 replace health_sat=1 if hlsat==3 gen health_verysat=0 replace health_verysat=1 if hlsat==4 gen notdisabled=. replace notdisabled=0 if disabled==1 replace notdisabled=1 if disabled==0 program drop _all gen group="" program table reg `1' male female [aw=pwt], cluster(idnum) noconstant test male=female replace chi`1'=r(p) in 1/2 replace group="men" in 1 replace group="women" in 2 reg `1' hhinclt30 hhinc30_49 hhinc50_99 hhincge100 [aw=pwt], cluster(idnum) noconstant test hhinclt30=hhinc30_49=hhinc50_99=hhincge100 replace chi`1'=r(p) in 3/6 replace group="hhinclt30" in 3 replace group="hhinc30_49" in 4 replace group="hhinc50_99" in 5 replace group="hhincge100" in 6 reg `1' agelt20 age20_29 age30_39 age40_49 age50_59 age60_69 age70_79 age80_89 age90_99 [aw=pwt], cluster(idnum) noconstant test agelt20=age20_29=age30_39=age40_49=age50_59=age60_69=age70_79=age80_89=age90_99 replace chi`1'=r(p) in 7/15 replace group="agelt20" in 7 replace group="age20_29" in 8 replace group="age30_39" in 9 replace group="age40_49" in 10 replace group="age50_59" in 11 replace group="age60_69" in 12 replace group="age70_79" in 13 replace group="age80_89" in 14 replace group="age90_99" in 15 reg `1' age18_24 age25_34 age35_44 age45_54 age55_64 age65_74 agege75 [aw=pwt], cluster(idnum) noconstant test age18_24=age25_34=age35_44=age45_54=age55_64=age65_74=agege75 replace chi`1'=r(p) in 16/22 replace group="age18_24" in 16 replace group="age25_34" in 17 replace group="age35_44" in 18 replace group="age45_54" in 19 replace group="age55_64" in 20 replace group="age65_74" in 21 replace group="agege75" in 22 reg `1' white black asian hispanic [aw=pwt], cluster(idnum) noconstant test white=black=asian=hispanic replace chi`1'=r(p) in 23/26 replace group="white" in 23 replace group="black" in 24 replace group="asian" in 25 replace group="hispanic" in 26 reg `1' lths hsed somecoll colled gtcoll [aw=pwt], cluster(idnum) noconstant test lths=hsed=somecoll=colled=gtcoll replace chi`1'=r(p) in 27/31 replace group="lths" in 27 replace group="hsed" in 28 replace group="somecoll" in 29 replace group="colled" in 30 replace group="gtcoll" in 31 reg `1' married notmarried [aw=pwt], cluster(idnum) noconstant test married=notmarried replace chi`1'=r(p) in 32/33 replace group="married" in 32 replace group="notmarried" in 33 reg `1' life_notatall life_notsat life_sat life_verysat [aw=pwt], cluster(idnum) noconstant test life_notatall=life_notsat=life_sat=life_verysat replace chi`1'=r(p) in 34/37 replace group="life_notatall" in 34 replace group="life_notsat" in 35 replace group="life_sat" in 36 replace group="life_verysat" in 37 reg `1' health_notatall health_notsat health_sat health_verysat [aw=pwt], cluster(idnum) noconstant test health_notatall=health_notsat=health_sat=health_verysat replace chi`1'=r(p) in 38/41 replace group="health_notatall" in 38 replace group="health_notsat" in 39 replace group="health_sat" in 40 replace group="health_verysat" in 41 reg `1' disabled notdisabled [aw=pwt], cluster(idnum) noconstant test disabled=notdisabled replace chi`1'=r(p) in 42/43 replace group="disabled" in 42 replace group="notdisabled" in 43 end program pain gen chi`1'=. table `1' end pain greater0 pain greater3 pain pain keep group chi* keep if chigreater0~=. sort group save merge, replace use painbydemo, clear sort group merge group using merge tab _merge drop _merge save painbydemo, replace /* Count the number of people in each subgroup */ program drop _all use pain, clear keep if greater0~=. bysort idnum: gen n=_n keep if n==1 drop n generate group="" program table sum `3' [aw=pwt] if `4' & `3'~=. replace N`3'=r(N) in `1' replace group="`2'" in `1' end program pain gen N`1'=. table 1 men `1' sex==1 table 2 women `1' sex==2 table 3 hhinclt30 `1' hhinc>=1&hhinc<=3 table 4 hhinc30_49 `1' hhinc>=4&hhinc<=5 table 5 hhinc50_99 `1' hhinc>=6&hhinc<=7 table 6 hhincge100 `1' hhinc>7&hhinc<98 table 7 agelt20 `1' age<20 table 8 age20_29 `1' age>=20&age<30 table 9 age30_39 `1' age>=30&age<40 table 10 age40_49 `1' age>=40&age<50 table 11 age50_59 `1' age>=50&age<60 table 12 age60_69 `1' age>=60&age<70 table 13 age70_79 `1' age>=70&age<80 table 14 age80_89 `1' age>=80&age<90 table 15 age90_99 `1' age>=90&age<100 table 16 age18_24 `1' age>=18&age<=24 table 17 age25_34 `1' age>=25&age<=34 table 18 age35_44 `1' age>=35&age<=44 table 19 age45_54 `1' age>=45&age<=54 table 20 age55_64 `1' age>=55&age<=64 table 21 age65_74 `1' age>=65&age<=74 table 22 agege75 `1' age>=75 table 23 white `1' race_1==1&hispanic!=1&race_2==. table 24 black `1' race_1==2&hispanic!=1&race_2==. table 25 asian `1' race_1==3&hispanic!=1&race_2==. table 26 hispanic `1' hispanic==1 table 27 lths `1' educ<=8 table 28 hsed `1' educ==9 table 29 somecoll `1' educ>9&educ<=12 table 30 colled `1' educ==13 table 31 gtcoll `1' educ>13&educ<98 table 32 married `1' marital==2 table 33 notmarried `1' marital~=2&marital<8 table 34 life_notatall `1' lisat==1 table 35 life_notsat `1' lisat==2 table 36 life_sat `1' lisat==3 table 37 life_verysat `1' lisat==4 table 38 health_notatall `1' hlsat==1 table 39 health_notsat `1' hlsat==2 table 40 health_sat `1' hlsat==3 table 41 health_verysat `1' hlsat==4 table 42 disabled `1' disabled==1 table 43 notdisabled `1' disabled==0 end pain greater0 keep group Ngreater0 keep if Ngreater0~=. sort group save merge, replace use painbydemo, clear sort group merge group using merge tab _merge drop _merge sort order drop order order group meangreater0 meangreater3 meanpain chigreater0 chigreater3 chipain drop ngreater3 npain save painbydemo, replace outsheet using "P:\Projects\Other\PATS Analysis\PATS\Public\painbydemo_pwt.raw", replace