/*copyright Seth A. Berkowitz, MD MPH. Sept 15, 2020. All commercial use prohibited.*/ libname in "H:\Pulse Survey\Data"; run; data analysis_07; set in.pulse2020_puf_07; run; data analysis_08; set in.pulse2020_puf_08; run; data analysis_09; set in.pulse2020_puf_09; run; data analysis_10; set in.pulse2020_puf_10; run; data analysis_11; set in.pulse2020_puf_11; run; data analysis_12; set in.pulse2020_puf_12; run; data analysis; set analysis_07 analysis_08 analysis_09 analysis_10 analysis_11 analysis_12; run; data analysis1; set analysis; age = 2020 - TBIRTH_YEAR; if 18 le age le 65 then age_include = 1; if EGENDER = 1 then female = 0; if EGENDER = 2 then female = 1; if RRACE = 1 then race_eth = 1; *NH white; if RRACE = 2 then race_eth = 2; *NH black; if RRACE = 3 then race_eth = 4; *NH asian; if RRACE = 4 then race_eth = 5; *NH other/mixed; if RHISPANIC = 2 then race_eth = 3; *hispanic; if EEDUC = 1 then edu3cat = 1; *HS diploma; if EEDUC = 5 then edu3cat = 3; *>HS diploma; if EEDUC = 6 then edu3cat = 3; *>HS diploma; if EEDUC = 7 then edu3cat = 3; *>HS diploma; if MS = 1 then married = 1; if MS = 2 then married = 0; if MS = 3 then married = 0; if MS = 4 then married = 0; if MS = 5 then married = 0; if WRKLOSS = 1 then lost_job = 1; if SPNDSRC5 =1 then UI = 1; if SPNDSRC5 =-99 then UI = 0; if PRIFOODSUF = 1 then p_food_insuf = 0; if PRIFOODSUF = 2 then p_food_insuf = 0; if PRIFOODSUF = 3 then p_food_insuf = 1; if PRIFOODSUF = 4 then p_food_insuf = 1; if CURFOODSUF = 1 then food_insuf = 0; if CURFOODSUF = 2 then food_insuf = 0; if CURFOODSUF = 3 then food_insuf = 1; if CURFOODSUF = 4 then food_insuf = 1; if FOODCONF = 1 then not_conf_food = 1; if FOODCONF = 2 then not_conf_food = 1; if FOODCONF = 3 then not_conf_food = 0; if FOODCONF = 4 then not_conf_food = 0; if HLTHSTATUS = -99 then HLTHSTATUS = .; uninsured = 1; if HLTHINS1 = 1 or HLTHINS2 = 1 or HLTHINS3 = 1 or HLTHINS4 = 1 or HLTHINS5 = 1 or HLTHINS6 = 1 or HLTHINS7 = 1 or HLTHINS8 = 1 then uninsured = 0; if DELAY = 1 then delay_care = 1; if DELAY = 2 then delay_care = 0; if NOTGET = 1 then delay_noncovid_care = 1; if NOTGET = 2 then delay_noncovid_care = 0; if MORTLMTH =1 then missed_rent = 0; if MORTLMTH =2 then missed_rent = 1; if MORTCONF = 1 then not_conf_rent = 1; if MORTCONF = 2 then not_conf_rent = 1; if MORTCONF = 3 then not_conf_rent = 0; if MORTCONF = 4 then not_conf_rent = 0; if INCOME = -99 then INCOME = .; if INTEREST = 1 then phq_first = 0; if INTEREST = 2 then phq_first = 1; if INTEREST = 3 then phq_first = 2; if INTEREST = 4 then phq_first = 3; if DOWN = 1 then phq_second = 0; if DOWN = 2 then phq_second = 1; if DOWN = 3 then phq_second = 2; if DOWN = 4 then phq_second = 3; phq2 = sum(phq_first, phq_second); if phq2 = 0 then phq2_cut = 0; if phq2 = 1 then phq2_cut = 0; if phq2 = 2 then phq2_cut = 0; if phq2 = 3 then phq2_cut = 1; if phq2 = 4 then phq2_cut = 1; if phq2 = 5 then phq2_cut = 1; if phq2 = 6 then phq2_cut = 1; if ANXIOUS = 1 then gad_first = 0; if ANXIOUS = 2 then gad_first = 1; if ANXIOUS = 3 then gad_first = 2; if ANXIOUS = 4 then gad_first = 3; if WORRY = 1 then gad_second = 0; if WORRY = 2 then gad_second = 1; if WORRY = 3 then gad_second = 2; if WORRY = 4 then gad_second = 3; gad2 = sum(gad_first, gad_second); if gad2 = 0 then gad2_cut = 0; if gad2 = 1 then gad2_cut = 0; if gad2 = 2 then gad2_cut = 0; if gad2 = 3 then gad2_cut = 1; if gad2 = 4 then gad2_cut = 1; if gad2 = 5 then gad2_cut = 1; if gad2 = 6 then gad2_cut = 1; include = 0; if age_include =1 and lost_job = 1 and SPNDSRC1 ne 1 then include = 1; *adjust weights for repeated datasets; new_weight = pweight/6; run; *verify overall UI count; proc freq; table ui; weight new_weight; run; *create table 1 dataset, limit to first appearance of each respondant; data analysis_tab; set analysis1; where include=1; run; proc sort data = analysis_tab; by SCRAM week; run; *remove additional observations; data analysis_tab1; set analysis_tab; by SCRAM week; if first.scram ne 1 then delete; run; proc freq; table ui; weight new_weight; run; data in.analysis_tab; set analysis_tab1 (keep = include SCRAM new_weight ui age female race_eth edu3cat income THHLD_NUMPER married week EST_ST p_food_insuf food_insuf not_conf_food missed_rent not_conf_rent uninsured delay_care delay_noncovid_care phq2_cut gad2_cut); run; *MI; *dummy_code variables; data analysis2; set analysis1; if RRACE = 1 then nhblack = 0; if RRACE = 2 then nhblack = 1; if RRACE = 3 then nhblack = 0; if RRACE = 4 then nhblack = 0; if RRACE = 1 then nhasian = 0; if RRACE = 2 then nhasian = 0; if RRACE = 3 then nhasian = 1; if RRACE = 4 then nhasian = 0; if RRACE = 1 then oth_race = 0; if RRACE = 2 then oth_race = 0; if RRACE = 3 then oth_race = 0; if RRACE = 4 then oth_race = 1; if RHISPANIC = 2 then hispanic = 1; if RHISPANIC = 1 then hispanic = 0; if EEDUC = 1 then ls_HS_edu = 1; *HS diploma; if EEDUC = 5 then ls_HS_edu = 0; *>HS diploma; if EEDUC = 6 then ls_HS_edu = 0; *>HS diploma; if EEDUC = 7 then ls_HS_edu = 0; *>HS diploma; if EEDUC = 1 then hs_diploma = 0; *HS diploma; if EEDUC = 5 then hs_diploma = 0; *>HS diploma; if EEDUC = 6 then hs_diploma = 0; *>HS diploma; if EEDUC = 7 then hs_diploma = 0; *>HS diploma; if INCOME = 1 then INC1 = 1; if INCOME = 2 then INC1 = 0; if INCOME = 3 then INC1 = 0; if INCOME = 4 then INC1 = 0; if INCOME = 5 then INC1 = 0; if INCOME = 6 then INC1 = 0; if INCOME = 7 then INC1 = 0; if INCOME = 8 then INC1 = 0; if INCOME = 1 then INC2 = 0; if INCOME = 2 then INC2 = 1; if INCOME = 3 then INC2 = 0; if INCOME = 4 then INC2 = 0; if INCOME = 5 then INC2 = 0; if INCOME = 6 then INC2 = 0; if INCOME = 7 then INC2 = 0; if INCOME = 8 then INC2 = 0; if INCOME = 1 then INC3 = 0; if INCOME = 2 then INC3 = 0; if INCOME = 3 then INC3 = 1; if INCOME = 4 then INC3 = 0; if INCOME = 5 then INC3 = 0; if INCOME = 6 then INC3 = 0; if INCOME = 7 then INC3 = 0; if INCOME = 8 then INC3 = 0; if INCOME = 1 then INC4 = 0; if INCOME = 2 then INC4 = 0; if INCOME = 3 then INC4 = 0; if INCOME = 4 then INC4 = 1; if INCOME = 5 then INC4 = 0; if INCOME = 6 then INC4 = 0; if INCOME = 7 then INC4 = 0; if INCOME = 8 then INC4 = 0; if INCOME = 1 then INC5 = 0; if INCOME = 2 then INC5 = 0; if INCOME = 3 then INC5 = 0; if INCOME = 4 then INC5 = 0; if INCOME = 5 then INC5 = 1; if INCOME = 6 then INC5 = 0; if INCOME = 7 then INC5 = 0; if INCOME = 8 then INC5 = 0; if INCOME = 1 then INC6 = 0; if INCOME = 2 then INC6 = 0; if INCOME = 3 then INC6 = 0; if INCOME = 4 then INC6 = 0; if INCOME = 5 then INC6 = 0; if INCOME = 6 then INC6 = 1; if INCOME = 7 then INC6 = 0; if INCOME = 8 then INC6 = 0; if INCOME = 1 then INC7 = 0; if INCOME = 2 then INC7 = 0; if INCOME = 3 then INC7 = 0; if INCOME = 4 then INC7 = 0; if INCOME = 5 then INC7 = 0; if INCOME = 6 then INC7 = 0; if INCOME = 7 then INC7 = 1; if INCOME = 8 then INC7 = 0; run; *dummy code state; DATA analysis3; set analysis2; ARRAY dummys {*} 3. state_1 - state_56; DO i=1 TO 56; dummys(i) = 0; END; dummys( EST_ST ) = 1; RUN; proc freq data=analysis3; where include=1; table state_1 - state_56; run; *drop non-existant states; data analysis4; set analysis3 (drop = state_3 state_7 state_14 state_43 state_52 state_56); *wyoming is reference; run; proc freq data=analysis2; table include; run; *inspect missingness; proc means data=analysis4 nmiss; where include=1; var ui age female nhblack hispanic nhasian oth_race ls_HS_edu hs_diploma INC1 INC2 INC3 INC4 INC5 INC6 INC7 THHLD_NUMPER married week food_insuf p_food_insuf not_conf_food uninsured delay_care delay_noncovid_care gad2 phq2 missed_rent not_conf_rent state_1 -- state_56; run; proc corr data=analysis4; var ui age female nhblack hispanic nhasian oth_race ls_HS_edu hs_diploma INC1 INC2 INC3 INC4 INC5 INC6 INC7 THHLD_NUMPER married week food_insuf p_food_insuf not_conf_food uninsured delay_care delay_noncovid_care gad2 phq2 missed_rent not_conf_rent state_1 -- state_56; run; proc mi data=analysis4 nimpute=0 ; where include=1; var ui age female nhblack hispanic nhasian oth_race ls_HS_edu hs_diploma INC1 INC2 INC3 INC4 INC5 INC6 INC7 THHLD_NUMPER married week food_insuf p_food_insuf not_conf_food uninsured delay_care delay_noncovid_care gad2 phq2 missed_rent not_conf_rent state_1 -- state_56; ods select misspattern; run; *do MI; proc mi data= analysis4 nimpute=10 out=analysis_mi seed=54321; where include=1; var ui age female nhblack hispanic nhasian oth_race ls_HS_edu hs_diploma INC1 INC2 INC3 INC4 INC5 INC6 INC7 THHLD_NUMPER married week food_insuf p_food_insuf not_conf_food uninsured delay_care delay_noncovid_care gad2 phq2 state_1 -- state_55; run; *analyze; *health-related social needs; proc genmod data=analysis_mi; weight new_weight; where include = 1; class SCRAM; by _imputation_; model food_insuf = ui age female nhblack hispanic nhasian oth_race ls_HS_edu hs_diploma INC1 INC2 INC3 INC4 INC5 INC6 INC7 THHLD_NUMPER p_food_insuf married week state_1 -- state_55/ link = log dist = poisson; repeated subject = SCRAM/ type = ind modelse ecovb; ods output GEEModPEst=gmparms ParmInfo=gmpinfo GEERCov=gecovb; run; proc mianalyze parms=gmparms covb=gecovb parminfo=gmpinfo wcov bcov tcov; modeleffects Intercept ui ; run; proc genmod data=analysis_mi; weight new_weight; where include = 1; class SCRAM; by _imputation_; model not_conf_food = ui age female nhblack hispanic nhasian oth_race ls_HS_edu hs_diploma INC1 INC2 INC3 INC4 INC5 INC6 INC7 THHLD_NUMPER p_food_insuf married week state_1 -- state_55/ link = log dist = poisson; repeated subject = SCRAM/ type = ind modelse ecovb; ods output GEEModPEst=gmparms ParmInfo=gmpinfo GEERCov=gecovb; run; proc mianalyze parms=gmparms covb=gecovb parminfo=gmpinfo wcov bcov tcov; modeleffects Intercept ui ; run; proc genmod data=analysis_mi; weight new_weight; where include = 1; class SCRAM; by _imputation_; model missed_rent = ui age female nhblack hispanic nhasian oth_race ls_HS_edu hs_diploma INC1 INC2 INC3 INC4 INC5 INC6 INC7 THHLD_NUMPER married week state_1 -- state_55/ link = log dist = poisson; repeated subject = SCRAM/ type = ind modelse ecovb; ods output GEEModPEst=gmparms ParmInfo=gmpinfo GEERCov=gecovb; run; proc mianalyze parms=gmparms covb=gecovb parminfo=gmpinfo wcov bcov tcov; modeleffects Intercept ui ; run; proc genmod data=analysis_mi; weight new_weight; where include = 1; class SCRAM; by _imputation_; model not_conf_rent = ui age female nhblack hispanic nhasian oth_race ls_HS_edu hs_diploma INC1 INC2 INC3 INC4 INC5 INC6 INC7 THHLD_NUMPER married week state_1 -- state_55/ link = log dist = poisson; repeated subject = SCRAM/ type = ind modelse ecovb; ods output GEEModPEst=gmparms ParmInfo=gmpinfo GEERCov=gecovb; run; proc mianalyze parms=gmparms covb=gecovb parminfo=gmpinfo wcov bcov tcov; modeleffects Intercept ui ; run; *healthcare access; proc genmod data=analysis_mi; weight new_weight; where include = 1; class SCRAM ; by _imputation_; model uninsured = ui age female nhblack hispanic nhasian oth_race ls_HS_edu hs_diploma INC1 INC2 INC3 INC4 INC5 INC6 INC7 THHLD_NUMPER married week state_1 -- state_55/ link = log dist = poisson; repeated subject = SCRAM/ type = ind modelse ecovb; ods output GEEModPEst=gmparms ParmInfo=gmpinfo GEERCov=gecovb ; run; proc mianalyze parms=gmparms covb=gecovb parminfo=gmpinfo wcov bcov tcov; modeleffects Intercept ui ; run; proc genmod data=analysis_mi; weight new_weight; where include = 1; class SCRAM; by _imputation_; model delay_care = ui age female nhblack hispanic nhasian oth_race ls_HS_edu hs_diploma INC1 INC2 INC3 INC4 INC5 INC6 INC7 THHLD_NUMPER married week state_1 -- state_55/ link = log dist = poisson; repeated subject = SCRAM/ type = ind modelse ecovb; ods output GEEModPEst=gmparms ParmInfo=gmpinfo GEERCov=gecovb ; run; proc mianalyze parms=gmparms covb=gecovb parminfo=gmpinfo wcov bcov tcov; modeleffects Intercept ui ; run; proc genmod data=analysis_mi; weight new_weight; where include = 1; class SCRAM; by _imputation_; model delay_noncovid_care = ui age female nhblack hispanic nhasian oth_race ls_HS_edu hs_diploma INC1 INC2 INC3 INC4 INC5 INC6 INC7 THHLD_NUMPER married week state_1 -- state_55/ link = log dist = poisson; repeated subject = SCRAM/ type = ind modelse ecovb; ods output GEEModPEst=gmparms ParmInfo=gmpinfo GEERCov=gecovb; run; proc mianalyze parms=gmparms covb=gecovb parminfo=gmpinfo wcov bcov tcov; modeleffects Intercept ui ; run; *mental health; proc genmod data=analysis_mi; weight new_weight; where include = 1; class SCRAM; by _imputation_; model phq2_cut = ui age female nhblack hispanic nhasian oth_race ls_HS_edu hs_diploma INC1 INC2 INC3 INC4 INC5 INC6 INC7 THHLD_NUMPER married week state_1 -- state_55/ link = log dist = poisson; repeated subject = SCRAM/ type = ind modelse ecovb; ods output GEEModPEst=gmparms ParmInfo=gmpinfo GEERCov=gecovb; run; proc mianalyze parms=gmparms covb=gecovb parminfo=gmpinfo wcov bcov tcov; modeleffects Intercept ui ; run; proc genmod data=analysis_mi; weight new_weight; where include = 1; class SCRAM; by _imputation_; model gad2_cut = ui age female nhblack hispanic nhasian oth_race ls_HS_edu hs_diploma INC1 INC2 INC3 INC4 INC5 INC6 INC7 THHLD_NUMPER married week state_1 -- state_55/ link = log dist = poisson; repeated subject = SCRAM/ type = ind modelse ecovb; ods output GEEModPEst=gmparms ParmInfo=gmpinfo GEERCov=gecovb; run; proc mianalyze parms=gmparms covb=gecovb parminfo=gmpinfo wcov bcov tcov; modeleffects Intercept ui ; run;