FOCUS AREAS

Graphics

scatter plot with symbol characters scatter plot with symbol images
Base SAS: ODS Graphics Procedure: SGPLOT

/* This program requires SAS 9.4 TS Level 1M1 or later */
%let gpath='.';
%let car='./Car_Trans.png';
%let truck='./Truck_Trans.png';
%let dpi=100;

data class;
  set sashelp.class(where=(age < 13));
  if name='Thomas' then weight=65;
  if name='Louise' then height=55;
run;

ods html close;

/*--Scatter Plot with Other Symbols 9.4--*/
ods listing gpath=&gpath image_dpi=&dpi style=htmlblue;
ods graphics / reset attrpriority=none width=5in height=3.75in imagename='Symbols_Char_94';
title 'Weight by Height for Age < 13'; 
footnote j=l 'Symbols from Font Character';
proc sgplot data=class;
  symbolchar name=Male char='2642'x / scale=1.6 textattrs=(weight=bold) voffset=0.1;
  symbolchar name=Female char='2640'x  / scale=1.6 textattrs=(weight=bold);
  styleattrs datasymbols=(Male Female);
  scatter x=height y=weight / group=sex markerattrs=(size=48);
  keylegend / location=inside position=topleft across=1 autoitemsize;
  yaxis grid integer offsetmin=0.1 offsetmax=0.1;
  xaxis grid integer;
  run;
  
/*--Adjust data--*/
data cars;
  set sashelp.cars(where=(make in ('BMW', 'Porsche') and horsepower > 300 and 
                          horsepower < 350 and MSRP > 50000));
  keep make horsepower mpg_city;
  horsepower=horsepower*(1+0.11*ranuni(3));
  mpg_city=mpg_city*(1-0.05*ranuni(3));
  if make='BMW' and horsepower > 347 then horsepower+5;
  if make='BMW' and mpg_city > 17.4 then mpg_city+1;
  if make='BMW' and horsepower < 335 then mpg_city=mpg_city-0.5;
run;

/*--Scatter Plot with Image Symbols 9.4--*/
ods listing gpath=&gpath image_dpi=&dpi style=htmlblue;
ods graphics / reset attrpriority=none width=5in height=3.75in imagename='Symbols_Image_94';
title 'Mileage by Horsepower by Type'; 
footnote j=l 'Symbols from Image';
proc sgplot data=cars noautolegend;
  symbolimage name=BMW image=&car / scale=1;
  symbolimage name=Porsche image=&truck / scale=1;
  styleattrs datasymbols=(BMW Porsche);
  scatter x=horsepower y=mpg_city / group=make markerattrs=(size=80);
  yaxis grid integer offsetmin=0.1 offsetmax=0.1;
  xaxis grid ;
  run;

title;
footnote;