PLOT Procedure
Example 4: Producing Multiple Plots per Page
Features: |
- PROC PLOT statement options: :
- HPERCENT=
- VPERCENT=
|
Data set: |
DJIA |
This example puts three
plots on one page of output.
Program
options formchar="|----|+|---+=|-/\<>*" pagesize=40 linesize=120;
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 vpercent=50 hpercent=50;
plot high*year='*';
plot low*year='o';
plot high*year='*' low*year='o' / overlay box;
title 'Plots of the 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. The PAGESIZE= option sets the number of lines of output
to 40, and the LINESIZE= option sets the line size in the output window
to 120 characters.
options formchar="|----|+|---+=|-/\<>*" pagesize=40 linesize=120;
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
;
Specify the plot sizes. VPERCENT=
specifies that 50% of the vertical space on the page of output is
used for each plot. HPERCENT= specifies that 50% of the horizontal
space is used for each plot.
proc plot data=djia vpercent=50 hpercent=50;
Create the first plot. This
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.
Create the second plot.This
plot request plots the values of Low on the vertical axis and the
values of Year on the horizontal axis. It also specifies an asterisk
as the plotting symbol.
Create the third plot. The
first plot request plots High on the vertical axis, plots Year on
the horizontal axis, and specifies an asterisk as a plotting symbol.
The second plot request plots Low on the vertical axis, plots Year
on the horizontal axis, and specifies an 'o '
as a plotting symbol. OVERLAY superimposes the second plot onto the
first. BOX draws a box around the plot. OVERLAY and BOX apply to both
plot requests.
plot high*year='*' low*year='o' / overlay box;
title 'Plots of the Dow Jones Industrial Average';
title2 'from 1968 to 2008';
run;
Copyright © SAS Institute Inc. All rights reserved.