/* The following lines should match the import routine */
libname library '~/data/anes';
%LET dataset = anes ;
proc freq data=library.&dataset;
tables VCF0013 VCF0302 VCF0702 VCF0717 VCF0718 VCF0719 VCF0720 VCF0721 VCF0803 VCF0809 VCF0830 VCF0834 VCF0838 VCF0839 VCF0867;
run;
proc freq data=library.&dataset;
tables VCF0867*VCF0867A / missing;
run;
data library.as04;
set library.&dataset;
/*
* Note:
* The SAS syntax provided by ANES resets "don't know" (DK) responses and
* refusals to the missing value several variables. (At latest count:
* VCF0302, VCF0702, VCF0717, VCF0718, VCF0719, VCF0720, VCF0721, VCF0867.)
* This must be edited.
*/
party = .;
if (VCF0302=5) then party = 1;
if (VCF0302 in (2, 3, 4, 8, 9)) then party = 2;
if (VCF0302=1) then party = 3;
label party = "Party";
voter = .;
if (VCF0702 in (0,1)) then voter = 0;
if (VCF0702=2) then voter = 1;
label voter = "Voted?";
influencer = .;
if (VCF0717 in (0,1)) then influencer = 0;
if (VCF0717=2) then influencer = 1;
label influencer = "(Try to) influence others?";
attender = .;
if (VCF0718 in (0,1)) then attender = 0;
if (VCF0718=2) then attender = 1;
label attender = "Attended rally/meeting?";
worker = .;
if (VCF0719 in (0,1)) then worker = 0;
if (VCF0719=2) then worker = 1;
label worker = "Worked on campaign?";
displayer = .;
if (VCF0720 in (0,1)) then displayer = 0;
if (VCF0720=2) then displayer = 1;
label displayer = "Displayed button/sticker?";
donor = .;
if (VCF0721 in (0,1)) then donor = 0;
if (VCF0721=2) then donor = 1;
label donor = "Donated to campaign?";
activity = sum(voter, influencer, attender, worker, displayer, donor);
label activity = "Count of activities";
r_activity = .;
if (activity=0) then r_activity = 0;
if (activity=1) then r_activity = 1;
if (activity=2) then r_activity = 2;
if (activity>=3) then r_activity = 3;
label r_activity = "Activities levels";
partisan = 0;
if (activity>=2) and (voter=1) then partisan = 1;
label partisan = "Partisan: voter and activities";
conserv_r = .;
if (VCF0803 in (1,2,3,4,5,6,7)) then conserv_r = VCF0803 - 4;
if (VCF0803=9) then conserv_r = 0;
conserv_r_alt = conserv_r;
if (VCF0803=0) then conserv_r_alt = 0;
conserv_d = -conserv_r;
conserv_d_alt = conserv_d;
if (VCF0803=0) then conserv_d_alt = 0;
govtspend_d = .;
if (VCF0839 in (1,2,3,4,5,6,7)) then govtspend_d = VCF0839 - 4;
if (VCF0839=9) then govtspend_d = 0;
govtspend_d_alt = govtspend_d;
if (VCF0839=0) then govtspend_d_alt = 0;
govtspend_r = -govtspend_d;
govtspend_r_alt = govtspend_r;
if (VCF0839=0) then govtspend_r_alt = 0;
blackaid_r = .;
if (VCF0830 in (1,2,3,4,5,6,7)) then blackaid_r = VCF0830 - 4;
if (VCF0830=9) then blackaid_r = 0;
blackaid_r_alt = blackaid_r;
if (VCF0830=0) then blackaid_r_alt = 0;
blackaid_d = -blackaid_r;
blackaid_d_alt = blackaid_d;
if (VCF0830=0) then blackaid_d_alt = 0;
womenrole_r = .;
if (VCF0834 in (1,2,3,4,5,6,7)) then womenrole_r = VCF0834 - 4;
if (VCF0834=9) then womenrole_r = 0;
womenrole_r_alt = womenrole_r;
if (VCF0834=0) then womenrole_r_alt = 0;
womenrole_d = -womenrole_r;
womenrole_d_alt = womenrole_d;
if (VCF0834=0) then womenrole_d_alt = 0;
abortlegal_d = .;
if (VCF0838 in (1,2)) then abortlegal_d = VCF0838 - 3;
if (VCF0838 in (3,4)) then abortlegal_d = VCF0838 - 2;
if (VCF0838=9) then abortlegal_d = 0;
abortlegal_d_alt = abortlegal_d;
if (VCF0838=0) then abortlegal_d_alt = 0;
abortlegal_r = -abortlegal_d;
abortlegal_r_alt = abortlegal_r;
if (VCF0838=0) then abortlegal_r_alt = 0;
entitlement_r = .;
if (VCF0809 in (1,2,3,4,5,6,7)) then entitlement_r = VCF0809 - 4;
if (VCF0809=9) then entitlement_r = 0;
entitlement_r_alt = entitlement_r;
if (VCF0809=0) then entitlement_r_alt = 0;
entitlement_d = -entitlement_r;
entitlement_d_alt = entitlement_d;
if (VCF0809=0) then entitlement_d_alt = 0;
affact1_r = .;
if (VCF0867=1) then affact1_r = -1;
if (VCF0867=5) then affact1_r = 1;
if (VCF0867=8) then affact1_r = 0;
affact1_r_alt = affact1_r;
if (VCF0867=9) then affact1_r_alt = 0;
affact1_d = -affact1_r;
affact1_d_alt = affact1_d;
if (VCF0867=9) then affact1_d_alt = 0;
affact2_r = .;
if (VCF0867A in (1,2,4,5)) then affact2_r = VCF0867A - 3;
if (VCF0867A=7) then affact2_r = 0;
if (VCF0867A=8) and (VCF0867=1) then affact2_r = -1;
if (VCF0867A=8) and (VCF0867=5) then affact2_r = 1;
affact2_r_alt = affact2_r;
if (VCF0867A=9) then affact2_r_alt = 0;
affact2_d = -affact2_r;
affact2_d_alt = affact2_d;
if (VCF0867A=9) then affact2_d_alt = 0;
/* Subset data to years of analysis: 1994-2000 */
if (VCF0004 in (1994,1996,1998,2000)) ;
run;
data library.as04_d;
set library.as04;
/* Subset to only Democrats. */
if (party=1) ;
run;
data library.as04_r;
set library.as04;
/* Subset to only Republicans. */
if (party=3) ;
run;
proc format;
value party_f 1 = "Democrat"
2 = "Independent"
3 = "Republican";
value no_yes_f 0 = "No" 1 = "Yes";
value threeplus_f 3 = "3+";
run;