Example 1. Ordering Axis Tick Marks with SAS Datetime Values


Example 1. Ordering Axis Tick Marks with SAS Datetime Values

Features:

AXIS statement options:

  • COLOR =

  • LABEL=

  • MAJOR=

  • MINOR=

  • OFFSET=

  • ORDER=

FOOTNOTE statement option:

  • HEIGHT=

SYMBOL statement options:

  • CI=

  • CV=

  • INTERPOL=

  • WIDTH=

GOPTIONS statement options:

  • FTITLE=

  • GUNIT=

  • HTEXT=

  • HTITLE=

Sample library member: GAXTMDV1

click to expand

This example uses SAS datetime values with an AXIS statement s ORDER= option to set the major tick marks on the horizontal axis. It adjusts the position of the first and last major tick marks.

The example also uses HILOCTJ interpolation in a SYMBOL statement to join minimum and maximum values. The default unit specification for heights in the graph are percent of the graphics output area as specified by GUNIT= in the GOPTIONS statement. The GOPTIONS statement also specifies the default fonts for TITLE1 and for other text.

Set the graphics environment. GUNIT= specifies the units in percent of the graphics output area. HTITLE= specifies the height for TITLE1 text. HTEXT= specifies the height for all other text. FTITLE= specifies SWISSB as the font for TITLE1.

 goptions reset=global gunit=pct border           cback=white           colors=(black blue green red)           ftitle=swissb ftext=swiss htitle=6           htext=4; 

Create the data set. DOWHLC contains the high, low, and close values of the Dow Jones Industrial index for each business day for a month.

 data dowhlc;       input date date9. high low close;       format date date9.;       datalines; 
 02JAN1997   6511.38 6318.96 6442.49  03JAN1997   6586.42 6437.10 6544.09  ...  more data lines  ...  30JAN1997   6621.82 6481.75 6600.66  31JAN1997   6621.82 6481.75 6600.66  ; 

Prepare the data for a high-low plot. DOWHLC2 generates three records for each date, storing each date s high, low, and close values in variable DOW.

 data dowhlc2;     set dowhlc;     drop high low close;     dow=high; output;     dow=low; output;     dow=close; output; 

Define titles and footnote. HEIGHT=3 in the FOOTNOTE statement overrides the height specified by HTEXT= in the GOPTIONS statement.

 title1 'Dow Jones High-Low-Close';  title2 'January, 1997';  footnote height=3 justify=right 'GAXTMDV1 

Define symbol characteristics. INTERPOL=HILOCTJ specifies that the minimum and maximum values of DOW are joined by a vertical line with a horizontal tick mark at each end. The close values are joined by straight lines. CV= colors the vertical lines, and CI= colors the line that joins the close values. WIDTH= controls the thickness of the line that joins the close points.

 symbol interpol=hiloctj         cv=blue         ci=red         width=2; 

Define characteristics of the horizontal axis. ORDER= uses a SAS date value to set the major tick marks. OFFSET= moves the first and last tick marks to make room for the tick mark value. COLOR= makes all axis elements red. MAJOR= and MINOR= modify the size and color of the major and minor tick marks.

 axis1 order=('30DEC96'd to '03FEB97'd by week)        offset=(3,3)        color=blue        label=none        major=(height=3 width=2)        minor=(number=6 color=red height=2 width=1)        width=3; 

Define characteristics of the vertical axis. LABEL=NONE suppresses the AXIS label. The COLOR= suboption in MINOR= overrides the COLOR= option.

 axis2 color=blue        label=none        major=(height=3)        minor=(number=4 color=red height=1)        offset=(2,2); 

Generate the plot and assign AXIS definitions. HAXIS= assigns AXIS1 to the horizontal axis, and VAXIS= assigns AXIS2 to the vertical axis.

 proc gplot data=dowhlc2;     plot dow*date / haxis=axis1                     vaxis=axis2;  run;  quit; 



SAS.GRAPH 9.1 Reference, Volumes I and II
SAS.GRAPH 9.1 Reference, Volumes I and II
ISBN: N/A
EAN: N/A
Year: 2004
Pages: 342

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net