Examples


Example 1: Specifying Color Text

Procedure features:

  • GPRINT procedure options:

    • CTEXT=

Other features:

  • GOPTIONS statement

  • TIMEPLOT procedure

Sample library member: GPRCOLOR

This example creates the REFLIB.DOWHLC data set and generates a graph with color text from output that is produced by the TIMEPLOT procedure. The TIMEPLOT procedure is not a graphics procedure and produces text output only. (See Base SAS Procedures Guide for details on the TIMEPLOT procedure.)

The first part of this example uses the TIMEPLOT procedure with the newly created REFLIB.DOWHLC data set as input to produce Output 38.1:

Output 38.1: SAS Output from the TIMEPLOT Procedure
start example
 date        min                                                             max                   6310                                                           6960                  *------------------------------------------------------------------*  02JAN1997        l-----------c------h                                              03JAN1997                    l---------c----h                                      06JAN1997                           l-----c------h                                 07JAN1997                        l-----------c-h                                   08JAN1997                           l---c--------h                                 09JAN1997                            l----------c----h                              10JAN1997                             l---------------c--h                         13JAN1997                                        l-----c-----h                     14JAN1997                                            l------c-----h                15JAN1997                                          l-----c------h                  16JAN1997                                            l-------c----h                17JAN1997                                                l---------c--h            20JAN1997                                                     l-----@              21JAN1997                                                    l----------c----h     22JAN1997                                                       l----c-----h       23JAN1997                                               l---c------------------h   24JAN1997                                       l------c---------h                  27JAN1997                                    l----c--------h                       28JAN1997                                     l---c---------------h                29JAN1997                                       l---h------c                        30JAN1997                                               l---------c--h             31JAN1997                                                    l---c---------h                       *------------------------------------------------------------------* 
end example
 

The second part of this example takes the output generated by the TIMEPLOT procedure and converts it to a graph by using the GPRINT procedure. Figure 38.3 on page 1154 shows the graph with color text, a title, and a footnote:

click to expand
Figure 38.3: GPRINT Procedure Output with Enhanced Text (GPRCOLOR)

Assign the libref and set the graphics environment. HTEXT= assigns the height for the text in the default unit, cells .

 libname reflib '  SAS-data-library  ';  goptions reset=global border cback=white           colors=(black blue green red)           ftitle=swissb htitle=3pct           htext=.8 ftext=none           hsize=7in vsize=5in; 

Assign the fileref OUT to the external file.

 *filename out '  external-file  '; 

Create the data set REFLIB.DOWHLC.

 data reflib.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   6845.03  6719.96  6823.86  31JAN1997   6912.37  6769.99  6813.09  ; 

Suppress the date line and page numbers and set the linesize and pagesize.

 options nodate nonumber linesize=80 pagesize=60; 

Specify the destination for all subsequent procedure output.

 proc printto print=out new;  run; 

Generate TIMEPLOT graph output. It is sent to external file.

 proc timeplot data=reflib.dowhlc;     plot low close high / overlay hiloc ref=mean(low)                           npp axis=6310 to 6960 by 10;     id date;  run; 

Reset destination for printed output to default.

 proc printto;  run; 

Define title and footnote.

 title 'TIMEPLOT of Dow-Jones Averages';  footnote h=3 pct f=swiss           j=l ' L=Low' ' C=Close' ' H=High'           j=r 'GPRCOLOR '; 

Generate graph from the external file and specify text color. CTEXT= assigns a color to the text produced by the GPRINT procedure.

 proc gprint fileref=out ctext=red;  run; 

Example 2: Adjusting the Size of Characters

Procedure features:

  • GPRINT statement options:

    • FILEREF=

Other features:

  • FILENAME statement

  • GOPTIONS statement

  • PRINT procedure

  • PRINTTO procedure

Data set: REFLIB.DOWHLC (see Example 1 on page 1153)

Sample library member: GPRCHARA

This example creates a graph from a text file and increases the size of the text. The first part of this example uses the PRINT procedure to create an external file that contains SAS output. The GPRINT procedure is used to import the text file into a graph. Because the LINESIZE= option ( columns ) is set to 76 and the PAGESIZE= option (rows) is set to 24, the output is small and occupies only a portion of the page, as shown in Figure 38.4 on page 1157:

click to expand
Figure 38.4: GPRINT Procedure Output with No Adjustments (GPRCHARA(a))

In the second part of this example, the number of columns and rows in the graphics output area is reduced with the HPOS= and VPOS= graphic options. Thus, the size of the characters in the graph increase, as shown in Figure 38.5 on page 1157:

click to expand
Figure 38.5: GPRINT Procedure Output with Adjusted Sizing (GPRCHARA(b))

Assign the libref and set the graphics environment. FTEXT= in the GOPTIONS statement specifies the default hardware font. (This is the default setting.)

 libname reflib '  SAS-data-library  ';  goptions reset=global border cback=white           colors=(black blue green red)           ftitle=swissb ftext=none           hsize=7in vsize=5in           hpos=142 vpos=68; 

Assign the fileref DOW to the external file. The fileref DOW is associated with the external file where the output from PROC PRINT is stored.

 filename dow '  external-file  '; 

Suppress the date line and page numbers. Set the line and page size.

 options nodate nonumber linesize=76 pagesize=24; 

Specify the destination for all subsequent procedure output. The PRINTTO procedure directs the SAS output to the external file that the GPRINT procedure subsequently uses as input. PRINT= directs all printed procedure output to the file referenced by the fileref DOW. NEW causes the output file to be replaced each time the program is run.

 proc printto print=dow new;  run; 

Send the output to the destination file. The PRINT procedure generates the text and sends it to the external file specified by PROC PRINTTO.

 proc print data=reflib.dowhlc;  run; 

Reset destination for printed output to the default. The destination for printed output is reset to the default by resubmitting PROC PRINTTO with no options.

 proc printto;  run; 

Define title and footnote.

 title 'Dow-Jones Averages';  footnote h=3 pct f=swiss j=r 'GPRCHARA(a) '; 

Generate graph from the external file. FILEREF= specifies the external file that is used as input. NOCC is omitted because the input text file contains carriage -control characters.

 proc gprint fileref=dow;  run; 

Reduce HPOS= and VPOS= to increase cell size.

 goptions hpos=75 vpos=30; 

Define the footnote.

 footnote h=3 pct f=swiss j=r 'GPRCHARA(b) '; 

Generate adjusted graph.

 proc gprint fileref=dow;  run; 



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