PLOT Procedure

Example 2: Controlling the Horizontal Axis and Adding a Reference Line

Features:
PLOT statement options: :
HAXIS=
VREF=
Data set: DJIA
This example specifies values for the horizontal axis and draws a reference line from the vertical axis.

Program

options formchar="|----|+|---+=|-/\<>*";
data djia;
      input Year HighDate date7. High LowDate date7. Low;
      format highdate lowdate date7.;
      datalines;
1968 03DEC68   985.21 21MAR68   825.13
1969 14MAY69   968.85 17DEC69   769.93
...more data lines...
2006 27DEC06 12510.57 20JAN06 10667.39
2007 09OCT07 14164.53 05MAR07 12050.41
2008 02MAY08 13058.20 10OCT08  8451.19
;
proc plot data=djia;
   plot high*year='*'
     / haxis=1965 to 2020 by 10 vref=3000;
   
title 'High Values of Dow Jones Industrial Average';
title2 'from 1968 to 2008';
run;

Program Description

Set the FORMCHAR option.Setting FORMCHAR to this exact string renders better HTML output when it is viewed outside of the SAS environment where SAS Monospace fonts are not available.
options formchar="|----|+|---+=|-/\<>*";
Create the DJIA data set. DJIA contains the high and low closing marks for the Dow Jones Industrial Average from 1968 to 2008. The DATA step creates this data set.
data djia;
      input Year HighDate date7. High LowDate date7. Low;
      format highdate lowdate date7.;
      datalines;
1968 03DEC68   985.21 21MAR68   825.13
1969 14MAY69   968.85 17DEC69   769.93
...more data lines...
2006 27DEC06 12510.57 20JAN06 10667.39
2007 09OCT07 14164.53 05MAR07 12050.41
2008 02MAY08 13058.20 10OCT08  8451.19
;
Create the plot. The plot request plots the values of High on the vertical axis and the values of Year on the horizontal axis. It also specifies an asterisk as the plotting symbol.
proc plot data=djia;
   plot high*year='*'
Customize the horizontal axis and draw a reference line. HAXIS= specifies that the horizontal axis will show the values 1968 to 2008 in ten-year increments. VREF= draws a reference line that extends from the value 3000 on the vertical axis.
     / haxis=1965 to 2020 by 10 vref=3000;
Specify the titles.
   
title 'High Values of Dow Jones Industrial Average';
title2 'from 1968 to 2008';
run;

Output

Plot with Reference Line
High Values of Dow Jones Industrial Average