*include goptions; %include macros(catplot); goptions vsize=7 htext=1.3; Title h=1.7 'Race and Politics in the 1980 Presidential vote' h=2 a=-90 ' '; /* allow space on right for pscale */ title2 h=1.4 'Observed Logits'; proc format; value race 0='NonWhite' 1='White'; data vote; input @10 race view reagan carter; format race race.; reagan= reagan + .5; *-- allow for 0 values; carter= carter + .5; total = reagan + carter; preagan = reagan / total; logit = log ( reagan / carter); cards; White 1 1 1 12 White 1 2 13 57 White 1 3 44 71 White 1 4 155 146 White 1 5 92 61 White 1 6 100 41 White 1 7 18 8 NonWhite 0 1 0 6 NonWhite 0 2 0 16 NonWhite 0 3 2 23 NonWhite 0 4 1 31 NonWhite 0 5 0 8 NonWhite 0 6 2 7 NonWhite 0 7 0 4 ; data votes; set vote; votes= reagan; votefor='REAGAN'; output; votes= carter; votefor='CARTER'; output; data pscale; xsys = '1'; * percent values for x; ysys = '2'; * data values for y; do prob = .01,.05,.1,.25,.5,.75,.9; logit = log( prob / (1-prob) ); * convert to logit; y = logit; x = 99 ; function='MOVE '; output; * tick marks; x = 100; function='DRAW '; output; text = put(prob,4.3); position='6'; * values; * style='DUPLEX'; function='LABEL '; output; end; ysys='1'; x=100.1; y=99.5; * axis label; text='Prob'; output; proc gplot data=vote; plot logit * view = race / haxis=axis2 hminor=0 vaxis=axis1 frame anno=pscale; symbol1 i=join v=+ h=1.5 c=black; symbol2 i=join v=square h=1.5 c=red ; axis2 label=(h=1.5 'Conservativism') offset=(2); axis1 order=(-5 to 2) offset=(0,3) label=(h=1.5 a=90 'LOGIT(Reagan / Carter)'); %gskip; proc logistic nosimple data=vote; model reagan/total = race view; proc catmod data=votes order=data; weight votes; response / out=predict; model votefor = race view / noiter ; title2 h=1.4 'Nominal Main Effects of Race and Political View (90% CI)'; run; %catplot(data=predict, class=race, x=view, z=1.65, anno=pscale); %gskip; proc catmod data=votes order=data; direct view; weight votes; response / out=predict; model votefor = race view / noiter ; title2 h=1.4 'Linear Effect for Political View (90% CI)'; run; %catplot(data=predict, class=race, x=view, z=1.65, anno=pscale); %gskip; proc catmod data=votes order=data; direct view; weight votes; response / out=predict; model votefor = race|view / noiter ; title2 h=1.4 'Separate slopes for Political View (90% CI)'; run; %catplot(data=predict, class=race, x=view, z=1.65, anno=pscale); %gfinish