/* Create a scatter plot version of New York Times graphic. */ /* data from http://www.nytimes.com/imagepages/2012/09/30/opinion/30coontz-gr1.html?ref=sunday */ proc format; value Gain low-< -10 ="Large Loss" /* [low,-10) */ -10 -< -5 ="Loss" /* [-10, -5) */ -5 - 5 ="No Change" /* [ -5, 5] */ 5 - 10 ="Gains" /* ( 5, 10] */ 10 - high="Large Gains";/*( 10, high] */ run; data Jobs; input Title $20. PctFemale1980 PctFemale2010; Diff = PctFemale2010 - PctFemale1980; label PctFemale1980="Percent Female (1980)" PctFemale2010="Percent Female (2010)"; format Diff Gain.; datalines; Secretary 99 98 Hygienist 98 98 Nurse 96 91 Housekeeper 87 89 Paralegal 70 89 Social worker 64 81 Teacher (K-8) 75 80 Physical Therapist 72 72 Healthcare Manager 50 70 Welfare Aide 90 67 Education Manager 37 64 Accountants 36 62 HR Manager 35 61 Teacher (HS) 55 60 Real Estate 47 53 Bus Driver 48 51 Editor/Reporter 48 48 Mail Carrier 12 39 Lawyer 14 36 Doctor 14 36 Manager 26 34 Computer Scientist 21 29 Dentist 6 28 Architect 8 27 Computer Programmer 28 24 CEO 24 23 Police 5 17 Aero Engineer 3 12 Elect Engineer 4 10 Telecom Repair 10 8 Mech Engineer 1 8 Welder 8 6 Pilot 1 5 Electrician 2 2 Auto Mechanic 1 1 ; proc sort data=Jobs; by descending Diff; run; /* set up attribute map: http://blogs.sas.com/content/graphicallyspeaking/2012/02/27/roses-are-red-violets-are-blue/ Colors: http://support.sas.com/documentation/cdl/en/graphref/65389/HTML/default/viewer.htm#p0ekhb3mdqahk3n15wzt55qtctr7.htm */ data Attrs; length Value $20 MarkerColor $20; ID = "Jobs"; Value = putn( 15,"Gain."); MarkerColor = "DarkGreen "; output; Value = putn( 8,"Gain."); MarkerColor = "GrayishGreen"; output; Value = putn( 0,"Gain."); MarkerColor = "MediumGray "; output; Value = putn( -8,"Gain."); MarkerColor = "DarkOrange "; output; Value = putn(-15,"Gain."); MarkerColor = "DarkRed "; output; run; ods graphics / width=950 height=900; proc sgplot data=Jobs dattrmap=Attrs; title "Gains by Women in the Workplace (1980-2010)"; lineparm x=0 y=0 slope=1 / transparency=0.5; scatter x=PctFemale1980 y=PctFemale2010 / group=Diff attrid=Jobs markerattrs=(symbol=CircleFilled) datalabel=Title datalabelattrs=(size=10) name="Scatter"; /* make room for labels by adding white space to plot */ xaxis grid offsetmin=0.2 offsetmax=0.1; yaxis grid offsetmin=0.2 offsetmax=0.1; keylegend "Scatter"; run;