Making a Scatterplot with a 45 degree line

DATA auto ;
  INPUT make $  mpg rep78 weight foreign ;
CARDS;
AMC     22 3 2930 0
AMC     17 3 3350 0
AMC     22 . 2640 0
Audi    17 5 2830 1
Audi    23 3 2070 1
BMW     25 4 2650 1
Buick   20 3 3250 0
Buick   15 4 4080 0
Buick   18 3 3670 0
Buick   26 . 2230 0
Buick   20 3 3280 0
Buick   16 3 3880 0
Buick   19 3 3400 0
Cad.    14 3 4330 0
Cad.    14 2 3900 0
Cad.    21 3 4290 0
Chev.   29 3 2110 0
Chev.   16 4 3690 0
Chev.   22 3 3180 0
Chev.   22 2 3220 0
Chev.   24 2 2750 0
Chev.   19 3 3430 0
Datsun  23 4 2370 1
Datsun  35 5 2020 1
Datsun  24 4 2280 1
Datsun  21 4 2750 1
;
RUN;

data auto;
 set auto;
  zmpg=mpg;
  zweight=weight;
  x=(_N_-20)/10;        /* HERE X and Y are created to produce a 45 degree */
   if x > 0 then x=x+2; /* line that covers the entire plot. */
  y=x;                  /* This will change depending on the ranges of your data points.*/
run;

PROC STANDARD data=auto mean=0 std=1 out=auto;
 var zmpg zweight;
RUN;

SYMBOL1 V=circle C=green I=none;
SYMBOL2 V=point  C=blue  I=join;

PROC GPLOT DATA=auto;
   PLOT zmpg*zweight x*y / overlay;
RUN;
 

How to cite this page

Report an error on this page or leave a comment

The content of this web site should not be construed as an endorsement of any particular web site, book, or software product by the University of California.