Anyway, I'm using some data published by Pew. The data was in SPSS format, but it's easy to import to SAS. Here is my code & output for the second assignment:
Code
libname mydata "/courses/u_coursera.org1/i_ 1006328/c_5333" access=readonly;
data new; set work.VALUES_MERGE;
/*Change labels for race and education */
LABEL RACETHN="Race and Ethnicity"
EDUC="Last Grade Completed";
/* include only those who always or nearly always vote */
IF OFTVOTE <= 2;
/* Exclude all who did not vote or voted for a 3rd party */
IF PARTY > 2;
/* Exclude those who didn't vote for a major party candidate */
IF PRESVOTE <=2;
/*Treat Don't Know / Refused to answer as missing data. */
IF RACETHN = 9 then RACETHN = .;
IF PARTY=9 THEN PARTY = . ;
IF EDUC=99 THEN EDUC = . ;
/* Let those who voted for the dem be 0, those who voted for repub be 1.
This will allow us to see % repub by doing an average of PRESCATEGORY*/
IF PRESVOTE = 1 then PRESCATEGORY=0;
ELSE IF PRESVOTE = 2 then PRESCATEGORY=1;
PROC SORT; by respid;
/* create the frequency tables */
PROC FREQ; TABLES OFTVOTE RACETHN EDUC PARTY;
Output
The FREQ Procedure
|
|
Frequency Missing = 258
|
|
Frequency Missing = 69
|
|
Frequency Missing = 22
|
|
Frequency Missing = 197
|
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.