*Northeast_chisq_test_01.10.12.sas

Author: Abt Associates, Inc.

Created: 1/10/12

Purpose: SAS code to run chi-square test of proportions to identify statistical

differences

between mail survey respondents and nonrespondents that participated in the

nonresponse

follow-up survey.

*variables tested are

(1) gender,

(2) educational attainment,

(3) employment,

(4) importance of aquatic ecosystems,

(5) hispanic/latino origin,

(6) race,

(7) race (minority/non-white), and

(8) household income.

*need to manually import the main survey and non-reponse data files separately

from excel; *labeled here as main_survey_data and NR_data respectively.;

*keep only the variables that are needed from each data set before merging;

Data main_survey_data_2; set main_survey_data;

sample="main";

race=max(q22_1,Q22_2,Q22_3,Q22_4,Q22_5);

if race~=5 then race_minor=1;

if race=5 then race_minor=2;

aquatic=Q2;

gender=Q13;

education=Q14;

employ=Q19;

income=Q23;

hisp=Q21;

drop region version batch

Q10_1 Q10_2 Q10_3 Q10_4 Q10_5 Q10_6 Q24 Q240 Q241 Q242 Q243

Q22_1 Q22_2 Q22_3 Q22_4 Q22_5

Q11_1 Q11_2 Q12 Q15 Q16 Q17 Q18_1 Q18_2 Q20

Q2 Q13 Q14 Q19 Q23 Q21;

RUN;

Data NR_data_2; set NR_data;

sample="nr";

drop Q_1 mode mail;

gender=Q_2; drop Q_2;

education=Q_3; drop Q_3;

drop Q_4 Q_5 Q_6 Q_7;

employ=Q_8; drop Q_8 Q_9;

aquatic=Q_10; drop Q_10 Q_11 Q12_1 Q12_2 Q12_3 Q12_4 Q12_5 Q12_6;

hisp=Q_15; drop q13 q_14 q_15;

race=max(Q_16_1,Q_16_2,Q_16_3,Q_16_4,Q_16_5,Q_16_6); drop Q_16_1 Q_16_2

Q_16_3 Q_16_4 Q_16_5 Q_16_6;

if race~=5 then race_minor=1;

if race=5 then race_minor=2;

drop q_17_1 q_17_2;

income=Q_18; drop q_18;

IDx=1*ID; drop ID; rename IDx=ID;

RUN;

***merge together the two data sets;

Data NE_combined; set NR_data_2 Main_survey_data_2;

RUN;

**************************

RUN Chi-sq test for gender

**************************;

proc sql; create table NE_gender as select

sample,gender,count(gender) as count

from NE_combined group by sample,gender;

quit;

proc sort data=NE_gender out=NE_gender nodupkey;

by sample gender; RUN;

Page 1
Data NE_gender; set NE_gender;

if gender="." then delete;

if gender=2 then genderx="female";

if gender=1 then genderx="male";

drop gender; rename genderx=gender;

RUN;

proc freq data=NE_gender order=data;

weight count;

table sample * gender / chisq;

RUN; *this generates results for gender without issue;

******************************

RUN Chi-sq test for employment

******************************;

proc sql; create table NE_employ as select

sample,employ,count(employ) as count

from NE_combined group by sample,employ;

quit;

proc sort data=NE_employ out=NE_employ nodupkey;

by sample employ; RUN;

Data NE_employ; set NE_employ;

if employ="." then delete;

if employ=2 then employx="unemployed";

if employ=1 then employx="employed";

drop employ; rename employx=employ;

RUN;

proc freq data=NE_employ order=data;

weight count;

table sample * employ / chisq;

RUN;

*********************************************

RUN Chi-sq test for hispanic or latino origin

*********************************************;

proc sql; create table NE_hisp as select

sample,hisp,count(hisp) as count

from NE_combined group by sample,hisp;

quit;

proc sort data=NE_hisp out=NE_hisp nodupkey;

by sample hisp; RUN;

Data NE_hisp; set NE_hisp;

if hisp="." then delete;

if hisp=2 then hispx="nothispanic";

if hisp=1 then hispx="hispanic";

drop hisp; rename hispx=hisp;

RUN;

proc freq data=NE_hisp order=data;

weight count;

table sample * hisp / chisq;

RUN;

*********************************************

RUN Chi-sq test for race(minority/non-white)

*********************************************;

proc sql; create table NE_race_minor as select

sample,race_minor,count(race_minor) as count

from NE_combined group by sample,race_minor;

quit;

proc sort data=NE_race_minor out=NE_race_minor nodupkey;

by sample race_minor; RUN;

Data NE_race_minor; set NE_race_minor;

if race_minor="." then delete;

if race_minor=2 then race_minorx="white";

if race_minor=1 then race_minorx="minority";

drop race_minor; rename race_minorx=race_minor;

RUN;

proc freq data=NE_race_minor order=data;

weight count;

table sample * race_minor / chisq;

RUN;

**********************************************

RUN Chi-sq test for educational attainment

Page 2
**********************************************;

proc sql; create table NE_education as select

sample,education,count(education) as count

from NE_combined group by sample,education;

quit;

proc sort data=NE_education out=NE_education nodupkey;

by sample education; RUN;

Data NE_education; set NE_education;

if education="." then delete;

RUN;

proc freq data=NE_education order=data;

weight count;

table sample * education / chisq;

RUN;

****************************************************

RUN Chi-sq test for importance of aquatic ecosystems

****************************************************;

proc sql; create table NE_aquatic as select

sample,aquatic,count(aquatic) as count

from NE_combined group by sample,aquatic;

quit;

proc sort data=NE_aquatic out=NE_aquatic nodupkey;

by sample aquatic; RUN;

Data NE_aquatic; set NE_aquatic;

if aquatic="." then delete;

RUN;

proc freq data=NE_aquatic order=data;

weight count;

table sample * aquatic / chisq;

RUN;

*****************************************************

RUN Chi-sq test for race with all categories included

*****************************************************;

proc sql; create table NE_race as select

sample,race,count(race) as count

from NE_combined group by sample,race;

quit;

proc sort data=NE_race out=NE_race nodupkey;

by sample race; RUN;

Data NE_race; set NE_race;

if race="." then delete;

RUN;

proc freq data=NE_race order=data;

weight count;

table sample * race / chisq;

RUN;

*the requirements for the proportional testing are not met so use fishers

exact test;

proc freq data=NE_race order=data;

weight count;

table sample * race / fisher;

RUN;

*****************************************************

RUN Chi-sq test for household income

*****************************************************;

proc sql; create table NE_income as select

sample,income,count(income) as count

from NE_combined group by sample,income;

quit;

proc sort data=NE_income out=NE_income nodupkey;

by sample income; RUN;

Data NE_income; set NE_income;

if income="." then delete;

RUN;

proc freq data=NE_income order=data;

weight count;

table sample * income / chisq;

RUN;

Page 3