~dricottone/replications

da6b7478a8a7062ac7fd75977abc3d9c9c6c8fc7 — Dominic Ricottone a month ago 34611f2
Incomplete work on AS04

Replication of Abramowitz, Saunders (2004).

Some issues remain in replication of Table 2.

Some changes were required of the SAS import procedure.
A AS04/Table 1.do => AS04/Table 1.do +82 -0
@@ 0,0 1,82 @@
clear all
cd "../data/anes"

use "anes_timeseries_cdf_stata_20220916.dta"
keep if inlist(VCF0004,1994,1996,1998,2000)
svyset VCF0006a [pweight=VCF0009z], vce(linearized)

recode VCF0302 (5=1 "Dem") (2 3 4 8 9=2 "Indep") (1=3 "Rep") (else=.), generate(party)

label variable party "Party ID"

/*
table VCF0302 party, missing
*/

recode VCF0702 (0 1=0 "Non") (2=1 "Voter") (else=.), generate(voter)
recode VCF0717 (0 1=0 "Non") (2=1 "Influencer") (else=.), generate(influencer)
recode VCF0720 (0 1=0 "Non") (2=1 "Influencer") (else=.), generate(displayer)
recode VCF0718 (0 1=0 "Non") (2=1 "Influencer") (else=.), generate(attender)
recode VCF0719 (0 1=0 "Non") (2=1 "Influencer") (else=.), generate(worker)
recode VCF0721 (0 1=0 "Non") (2=1 "Influencer") (else=.), generate(donor)

label variable voter "Voter?"
label variable influencer "(Try to) Influence others?"
label variable displayer "Display buttons/stickers?"
label variable attender "Attend rally/meeting?"
label variable worker "Work on campaign?"
label variable donor "Donate to campaign?"

/*
table VCF0702 voter, missing
table VCF0717 influencer, missing
table VCF0720 displayer, missing
table VCF0718 attender, missing
table VCF0719 worker, missing
table VCF0721 donor, missing
*/

egen activity = rowtotal(voter influencer displayer attender worker donor)
recode activity (0=0) (1=1) (2=2) (3 4 5 6=3 "3+"), generate(r_activity)

label variable activity "Count of activities"
label variable r_activity "Levels of activities"

/*
tab activity r_activity, missing
*/

generate partisan = voter & (influencer | displayer | attender | worker | donor)

label variable partisan "Partisan: voter and engaged in an activity"

/*
tab voter activity, missing
tab partisan voter, missing
tab partisan activity, missing
*/

// Activity - Voting
mean voter, over(party)
// Activity - Persuading others
mean influencer, over(party)
// Activity - Displaying button/stickers
mean displayer, over(party)
// Activity - Attending rally/meeting
mean attender, over(party)
// Activity - Working for party/candidate
mean worker, over(party)
// Activity - Contributing money
mean donor, over(party)

// Overall Activity Score
tab r_activity party, nofreq col
// Republican/3+ is off - 13.6 displayed as 13 instead of 14; probably to force percentages totaling to 100

// Active partisans
mean partisan, over(party)
// Independent is off - 21.0 displayed as 22 instead of 21

// Valid N
tab party


A AS04/Table 1.sas => AS04/Table 1.sas +28 -0
@@ 0,0 1,28 @@
/* The following lines should match the import routine */
libname library '~/data/anes';

/* Activities */
proc means data=library.as04 mean maxdec=2;
  var voter influencer displayer attender worker donor;
  class party;
  format voter influencer displayer attender worker donor no_yes_f. party party_f.;
run;

/* Overall Activity Scale score */
proc freq data=library.as04;
  tables r_activity*party / nofreq nopercent norow;
  format r_activity threeplus_f. party party_f.;
run;

/* Active partisans */
proc means data=library.as04 mean maxdec=2;
  var partisan;
  class party;
  format partisan no_yes_f. party party_f.;
run;

/* Party N */
proc freq data=library.as04;
  tables party / nocum nopercent;
  format party party_f.;
run;

A AS04/Table 2.sas => AS04/Table 2.sas +15 -0
@@ 0,0 1,15 @@
/* The following lines should match the import routine */
libname library '~/data/anes';

/* Democrats */
proc freq data=library.as04_d;
  tables (conserv_d_alt entitlement_d govtspend_d blackaid_d affact1_d affact2_d womenrole_d abortlegal_d)*activity / noprint measures;
run;
/* not matching on affact and womenrole */
/* close enough on abortlegal (reported .113 vs replicated .111) */

/* Republicans */
proc freq data=library.as04_r;
  tables (conserv_r entitlement_r govtspend_r blackaid_r affact1_r affact2_r womenrole_r abortlegal_r)*activity / noprint measures;
run;
/* not matching on affact */

A AS04/prep.sas => AS04/prep.sas +173 -0
@@ 0,0 1,173 @@
/* 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;

M data/anes/anes_timeseries_cdf_syntax_sas_20220916.sas => data/anes/anes_timeseries_cdf_syntax_sas_20220916.sas +18 -18
@@ 3,13 3,13 @@
/* ENCODING CP1252 */

/* The following line should contain the complete path and name of your raw data file */
FILENAME datafile 'anes_timeseries_cdf_syntax_rawdata_20220916.dat' ;
FILENAME datafile '~/data/anes/anes_timeseries_cdf_syntax_rawdata_20220916.dat' ;

/* The following line should contain the directory in which you wish your SAS file to be stored */
libname library '' ;
libname library '~/data/anes' ;

/* The following line contains the name (without the extension) for your SAS dataset */
%LET dataset = anes_tim ;
%LET dataset = anes ;

proc format library = library ;
   value VCF0013F


@@ 8000,7 8000,7 @@ LABEL
  IF VCF0290 >= 999 OR VCF0290 = 998 THEN VCF0290 =. ;
  IF VCF0291 >= 999 OR VCF0291 = 998 THEN VCF0291 =. ;
  IF VCF0301 = 0 THEN VCF0301 =. ;
  IF VCF0302 >= 9 OR VCF0302 = 8 THEN VCF0302 =. ;
  *IF VCF0302 >= 9 OR VCF0302 = 8 THEN VCF0302 =. ;
  IF VCF0303 = 0 THEN VCF0303 =. ;
  IF VCF0305 = 0 THEN VCF0305 =. ;
  IF VCF0306 >= 9 OR VCF0306 = 0 THEN VCF0306 =. ;


@@ 8220,7 8220,7 @@ LABEL
  IF VCF0675 = 9 THEN VCF0675 =. ;
  IF VCF0700 = 9 THEN VCF0700 =. ;
  IF VCF0701 = 0 THEN VCF0701 =. ;
  IF VCF0702 = 0 THEN VCF0702 =. ;
  *IF VCF0702 = 0 THEN VCF0702 =. ;
  IF VCF0703 = 0 THEN VCF0703 =. ;
  IF VCF0704 = 0 THEN VCF0704 =. ;
  IF VCF0704a = 0 THEN VCF0704a =. ;


@@ 8236,11 8236,11 @@ LABEL
  IF VCF0714 = 0 THEN VCF0714 =. ;
  IF VCF0715 = 0 THEN VCF0715 =. ;
  IF VCF0716 = 0 THEN VCF0716 =. ;
  IF VCF0717 = 0 THEN VCF0717 =. ;
  IF VCF0718 = 0 THEN VCF0718 =. ;
  IF VCF0719 = 0 THEN VCF0719 =. ;
  IF VCF0720 = 0 THEN VCF0720 =. ;
  IF VCF0721 = 0 THEN VCF0721 =. ;
  *IF VCF0717 = 0 THEN VCF0717 =. ;
  *IF VCF0718 = 0 THEN VCF0718 =. ;
  *IF VCF0719 = 0 THEN VCF0719 =. ;
  *IF VCF0720 = 0 THEN VCF0720 =. ;
  *IF VCF0721 = 0 THEN VCF0721 =. ;
  IF VCF0722 = 0 THEN VCF0722 =. ;
  IF VCF0723 = 0 THEN VCF0723 =. ;
  IF VCF0723a = 0 THEN VCF0723a =. ;


@@ 8273,12 8273,12 @@ LABEL
  IF VCF0749 = 99 THEN VCF0749 =. ;
  IF VCF0750 = 9 THEN VCF0750 =. ;
  IF VCF0801 >= 99 OR VCF0801 = 98 THEN VCF0801 =. ;
  IF VCF0803 = 0 THEN VCF0803 =. ;
  *IF VCF0803 = 0 THEN VCF0803 =. ;
  IF VCF0804 = 0 THEN VCF0804 =. ;
  IF VCF0805 = 0 THEN VCF0805 =. ;
  IF VCF0806 = 0 THEN VCF0806 =. ;
  IF VCF0808 = 0 THEN VCF0808 =. ;
  IF VCF0809 = 0 THEN VCF0809 =. ;
  *IF VCF0809 = 0 THEN VCF0809 =. ;
  IF VCF0811 >= 9 OR VCF0811 = 0 THEN VCF0811 =. ;
  IF VCF0813 = 0 THEN VCF0813 =. ;
  IF VCF0814 = 0 THEN VCF0814 =. ;


@@ 8298,14 8298,14 @@ LABEL
  IF VCF0827a >= 9 OR VCF0827a = 0 THEN VCF0827a =. ;
  IF VCF0828 = 0 THEN VCF0828 =. ;
  IF VCF0829 = 0 THEN VCF0829 =. ;
  IF VCF0830 = 0 THEN VCF0830 =. ;
  *IF VCF0830 = 0 THEN VCF0830 =. ;
  IF VCF0832 = 0 THEN VCF0832 =. ;
  IF VCF0833 = 9 THEN VCF0833 =. ;
  IF VCF0834 = 0 THEN VCF0834 =. ;
  *IF VCF0834 = 0 THEN VCF0834 =. ;
  IF VCF0836 = 0 THEN VCF0836 =. ;
  IF VCF0837 = 0 THEN VCF0837 =. ;
  IF VCF0838 = 0 THEN VCF0838 =. ;
  IF VCF0839 = 0 THEN VCF0839 =. ;
  *IF VCF0838 = 0 THEN VCF0838 =. ;
  *IF VCF0839 = 0 THEN VCF0839 =. ;
  IF VCF0840 = 9 THEN VCF0840 =. ;
  IF VCF0841 = 0 THEN VCF0841 =. ;
  IF VCF0842 = 0 THEN VCF0842 =. ;


@@ 8328,8 8328,8 @@ LABEL
  IF VCF0864 >= 8 OR VCF0864 = 0 THEN VCF0864 =. ;
  IF VCF0865 >= 8 OR VCF0865 = 0 THEN VCF0865 =. ;
  IF VCF0866 >= 8 OR VCF0866 = 0 THEN VCF0866 =. ;
  IF VCF0867 = 9 THEN VCF0867 =. ;
  IF VCF0867a >= 9 OR VCF0867a = 8 THEN VCF0867a =. ;
  *IF VCF0867 = 9 THEN VCF0867 =. ;
  *IF VCF0867a >= 9 OR VCF0867a = 8 THEN VCF0867a =. ;
  IF VCF0870 >= 8 OR VCF0870 = 0 THEN VCF0870 =. ;
  IF VCF0871 >= 8 OR VCF0871 = 0 THEN VCF0871 =. ;
  IF VCF0872 >= 9 OR VCF0872 = 8 THEN VCF0872 =. ;