Chapter Contents

Previous

Next
The PLOT Procedure

Example 12: Adjusting Labeling on a Plot with a Macro


Procedure features:
PLOT statement options
label variable in plot request
PLACEMENT=
Data set: CENSUS

This example illustrates the default placement of labels and uses a macro to adjust the placement of labels. The labels are values of a variable in the data set.


Program

options nodate pageno=1 linesize=120 pagesize=37;

 Note about code
%macro place(n);
   %if &n > 13 %then %let n = 13;
       placement=(
   %if &n <= 0 %then (s=center); %else (h=2 -2 : s=right left);
   %if &n = 1 %then (v=1 * h=0 -1 to -2 by alt);
   %else %if &n = 2 %then (v=1 -1 * h=0 -1 to -5 by alt);
   %else %if &n > 2 %then (v=1 to 2 by alt * h=0 -1 to -10 by alt);
   %if &n > 3 %then
       (s=center right left * v=0 1 to %eval(&n - 2) by alt *
       h=0 -1 to %eval(-3 * (&n - 2)) by alt *
       l=1 to %eval(2 + (10 * &n - 35) / 30)); )
   %if &n > 4 %then penalty(7)=%eval((3 * &n) / 2);
%mend;
proc plot data=census;
 Note about code
   plot density*crimerate=state $ state / box list=1
           haxis=by 1000 vaxis=by 250 %place(4);
   title 'A Plot of Population Density and Crime Rates';
run;










Output
No collisions occur in the plot. [HTML Output]
 [Listing Output]


Chapter Contents

Previous

Next

Top of Page

Copyright 1999 by SAS Institute Inc., Cary, NC, USA. All rights reserved.