~dricottone/replications

ref: eadd78ee3d07aba2f81377effb0387743b8c414f replications/AS04/prep.sas -rw-r--r-- 5.1 KiB
eadd78eeDominic Ricottone Add README 2 days ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
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;