TIMEPLOT Procedure

Example 2: Customizing an Axis and a Plotting Symbol

Features:

ID statement

PLOT statement arguments: :
using a plotting symbol
AXIS=
Other features:

LABEL statement

PROC FORMAT

SAS system options: : FMTSEARCH=

Data set: SALES

Details

This example demonstrates the following:
  • Specify the character to use as the plotting symbol
  • Specify the minimum and maximum values for the horizontal axis as well as the interval represented by each print position
  • Provide context for the points in the plot by printing in the listing the values of two variables that are not in the plot
  • Use a variable's label as a column heading in the listing
  • Create and uses a permanent format

Program

libname proclib
'SAS-library';
options formchar="|----|+|---+=|-/\<>*" fmtsearch=(proclib);
proc format library=proclib;
   value monthfmt 1='January'
                 2='February';
run;
proc timeplot data=sales;
   plot icebox='R' / axis=2500 to 3600 by 25;
   id month week;
   label icebox='Refrigerator';
        
   format month monthfmt.;
   title 'Weekly Sales of Refrigerators';
   title2 'for the';
   title3 'First Six Weeks of the Year';
run;

Program Description

Declare the PROCLIB SAS library.
libname proclib
'SAS-library';
Set the SAS system options.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. FMTSEARCH= adds the SAS library PROCLIB to the search path that is used to locate formats.
options formchar="|----|+|---+=|-/\<>*" fmtsearch=(proclib);
Create a format for the Month variable. PROC FORMAT creates a permanent format for Month. The LIBRARY= option specifies a permanent storage location so that the formats are available in subsequent SAS sessions. This format is used for examples throughout this chapter.
proc format library=proclib;
   value monthfmt 1='January'
                 2='February';
run;
Plot sales of refrigerators. The plot variable, Icebox, appears in both the listing and the output. The plotting symbol is 'R'. AXIS= sets the minimum value of the axis to 2500 and the maximum value to 3600. BY 25 specifies that each print position on the axis represents 25 units (in this case, dollars).
proc timeplot data=sales;
   plot icebox='R' / axis=2500 to 3600 by 25;
Label the rows in the listing. The values of the ID variables, Month and Week, are used to uniquely identify each row of the listing.
   id month week;
Apply a label to the sales column in the listing. The LABEL statement associates a label with the variable Icebox for the duration of the PROC TIMEPLOT step. PROC TIMEPLOT uses the label as the column heading in the listing.
   label icebox='Refrigerator';
        
Apply the MONTHFMT. format to the Month variable. The FORMAT statement assigns a format to use for Month in the report.
   format month monthfmt.;
Specify the titles.
   title 'Weekly Sales of Refrigerators';
   title2 'for the';
   title3 'First Six Weeks of the Year';
run;

Output

The column headings in the listing are the variables' names (for Month and Week, which have no labels) and the variable's label (for Icebox, which has a label). The plotting symbol is R (for Refrigerator).
Plot with Customized Axis and Plotting Symbol
Weekly Sales of Refrigerators