Examples


Example 1: Generating a Simple Bubble Plot

Procedure features:

  • BUBBLE statement option:

    • HAXIS=

Other features:

  • AXIS statement

  • FORMAT statement

Sample library member: GPLBUBL1

click to expand

This example shows a bubble plot in which each bubble represents a category of engineer. The plot shows engineers on the horizontal axis and average salaries on the vertical axis. Each bubble s vertical location is determined by the average salary for the category. Each bubble s size is determined by the number of engineers in the category: the more engineers , the larger the bubble.

Set the graphics environment.

 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. The data set JOBS contains average salary data for several categories of engineer. It also indicates the number of engineers in each category.

 data jobs;     length eng ;     input eng dollars num;     datalines;  Civil 27308 73273  Aero 29844 70192  Elec 22920 89382  Mech 32816 19601  Chem 28116 25541  Petro 18444 34833  ; 

Define titles and footnote.

 title1 'Member Profile';  title2 'Salaries and Number of Member Engineers';  footnote h=3 j=r 'GPLBUBL1 '; 

Define axis characteristics. OFFSET= specifies an offset for the tick marks so that bubbles near an axis are not clipped.

 axis1 offset=(5,5); 

Generate bubble plot. HAXIS= assigns the AXIS1 statement to the horizontal axis. The salary averages are assigned a dollar format.

 proc gplot data=jobs;     format dollars dollar9.;     bubble dollars*eng=num / haxis=axis1;  run;  quit; 

Example 2: Labeling and Sizing Plot Bubbles

Procedure features:

  • BUBBLE statement options:

    • BCOLOR=

    • BFONT=

    • BLABEL

    • BSIZE=

    • CAXIS=

    • HAXIS=

    • VAXIS=

    • VMINOR

Other features:

  • AXIS statement

Data set: JOBS on page 1121

Sample library member: GPLBUBL2

click to expand

This example modifies the code in Example 1. It shows how BUBBLE statement options control the appearance of bubbles and their labels. It also shows how AXIS statements can modify the plot axes.

Set the graphics environment.

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

Define titles and footnote.

 title1 'Member Profile';  title2 h=4 'Salaries and Number of Member Engineers';  footnote1 h=3 j=r 'GPLBUBL2 '; 

Define axis characteristics. AXIS1 suppresses the horizontal axis label and uses OFFSET= to move the first and last major tick mark values away from the vertical axes so bubbles are not clipped. AXIS2 uses ORDER= to set major tick mark intervals. This could be done with VAXIS= on the BUBBLE statement, but then you could not suppress the axis label and alter other axis characteristics.

 axis1 label=none        offset=(5,5)        width=3        value=(height=4);  axis2 order=(0 to 40000 by 10000)        label=none        major=(height=1.5)        minor=(height=1)        width=3        value=(height=4); 

Generate bubble plot. VMINOR= specifies one minor tick mark for the vertical axis. BCOLOR= colors the bubbles. BLABEL labels each bubble with the value of variable NUM, and BFONT= specifies the font for labeling text. BSIZE= increases the bubble sizes by increasing the scaling factor size to 12. CAXIS= colors the axis lines and all major and minor tick marks.

 proc gplot data=jobs;     format dollars dollar9. num comma7.0;     bubble dollars*eng=num / haxis=axis1                              vaxis=axis2                              vminor=1                              bcolor=red                              blabel                              bfont=swissi                              bsize=12                              caxis=blue;  run;  quit; 

Example 3: Adding a Right Vertical Axis

Procedure features:

  • BUBBLE2 statement options:

    • BCOLOR=

    • BSIZE=

    • CAXIS=

    • VAXIS=

Data set: JOBS on page 1121

Sample library member: GPLAXIS1

click to expand

This example modifies Example 2 on page 1122 to show how a BUBBLE2 statement generates a right vertical axis that displays the values of the vertical coordinates in a different scale from the scale that is used for the left vertical axis. Salary values are scaled by dollars on the left vertical axis and by yen on the right vertical axis.

BUBBLE and BUBBLE2 statement options control the size and appearance of the bubbles and their labels. In particular, the VAXIS options calibrate the axes so that the data points are identical and only one set of bubbles appears.

Note: If the data points are not identical, two sets of bubbles are displayed.

Set the graphics environment.

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

Create the data set JOBS2 and calculate variable YEN. The DATA step uses a SET statement to read the JOBS data set.

 data jobs2;     set jobs;     yen=dollars*125;  run; 

Define titles and footnote.

 title1 'Member Profile';  title2 h=4 'Salaries and Number of Member Engineers';  footnote j=r ' GPLAXIS1 '; 

Define horizontal-axis characteristics.

 axis1 offset=(5,5)        label=none        width=3        value=(h=4); 

Generate bubble plot with second vertical axis. In the BUBBLE statement, HAXIS= specifies the AXIS1 definition and VAXIS= scales the left axis. In the BUBBLE2 statement, VAXIS= scales the right axis. Both axes represent the same range of monetary values. The BUBBLE and BUBBLE2 statements ensure that the bubbles generated by each statement are identical by coordinating specifications on BCOLOR=, which colors the bubbles; BSIZE=, which increases the size of the scaling factor to 12; and CAXIS=, which colors the axis lines and all major and minor tick marks. Axis labels and major tick mark values use the default color, which is the first color in the colors list.

 proc gplot data=jobs2;     format dollars dollar7. num yen comma9.0;     bubble dollars*eng=num / haxis=axis1                              vaxis=10000 to 40000 by 10000                              hminor=0                              vminor=1                              blabel                              bfont=swissi                              bcolor=red                              bsize=12                              caxis=blue;     bubble2 yen*eng=num / vaxis=1250000 to 5000000 by 1250000                           vminor=1                           bcolor=red                           bsize=12                           caxis=blue;  run;  quit; 

Example 4: Plotting Two Variables

Procedure features:

  • PLOT statement options:

    • HAXIS=

    • HMINOR=

    • REGEQN

    • VAXIS=

Other features:

  • RUN- group processing

  • SYMBOL statement

Sample library member: GPLVRBL1

click to expand

In this example, the PLOT statement uses a plot request of the type y-variable * x-variable to plot the variable HEIGHT against the variable WEIGHT. The plot shows that weight generally increases with size.

This example then requests the same plot with some modifications. As shown by the following output, the second plot request specifies a regression analysis with confidence limits, and scales the range of values along the vertical and horizontal axes. It also displays the regression equation specified for the SYMBOL statement. Because the procedure supports RUN-group processing, you do not have to repeat the PROC GPLOT statement to generate the second plot.

click to expand

Set the graphics environment.

 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. STATS contains the heights and weights of numerous individuals.

 data stats;     input height weight;     datalines;  69.0  112.5  56.5   84.0    more data lines    67.0  133.0  57.5   85.0  ; 

Define title and footnotes.

 title 'Study of Height vs Weight';  footnote1 h=3 j=l ' Source: T. Lewis & L. R. Taylor';  footnote2      h=3 j=l '       Introduction to Experimental Ecology'      j=r 'GPLVRBL1(a) '; 

Generate a default scatter plot.

 proc gplot data=stats;     plot height*weight;    run; 

Redefine footnotes to make room for the regression equation.

 footnote1; /* this clears footnote1 */  footnote2 h=3 j=r 'GPLVRBL1(b) '; 

Define symbol characteristics. INTERPOL= specifies a cubic regression analysis with confidence limits for mean predicted values. VALUE=, HEIGHT=, and CV= specify a plot symbol, size, and color. CI=, CO=, and WIDTH= specify colors and a thickness for the interpolation and confidence-limits lines.

 symbol1 interpol=rcclm95         value=diamond         height=3         cv=red         ci=blue         co=green         width=2; 

Generate scatter plot with regression line. HAXIS= and VAXIS= define the range of axes values. HMINOR= specifies one minor tick mark between major tick marks. REGEQN displays the regression equation specified on the SYMBOL1 statement.

 plot height*weight / haxis=45 to 155 by 10                          vaxis=48 to 78 by 6                          hminor=1                          regeqn;  run;  quit; 

Example 5: Connecting Plot Data Points

Procedure features:

  • PLOT statement option:

    • CAXIS=

    • CTEXT

    • CVREF

    • HAXIS

    • HMINOR=

    • LVREF=

    • VAXIS=

    • VMINOR=

    • VREF

Other features:

  • SYMBOL statement

Sample library member: GPLDTPT1

click to expand

In this example, the PLOT statement uses a plot request of the type y-variable * x-variable to plot the variable HIGH against the variable YEAR to show the annual highs of the Dow Jones Industrial Average over several decades.

This example uses a SYMBOL statement to specify a plot symbol and connect data points with a straight line. In addition, the example shows how PLOT statement options can add reference lines and modify the axes (AXIS statements are not used).

Set the graphics environment.

 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. STOCKS contains yearly highs and lows for the Dow Jones Industrial Average, and the dates of the high and low values each year.

 data stocks;     input year @7 hdate date9. @15 high                @24 ldate date9. @32 low;     format hdate ldate date9.;     datalines;  1955  30DEC55  488.40  17JAN55  388.20  1956  06APR56  521.05  23JAN56  462.35    more data lines    1994 31JAN94 3978.36 04APR94 3593.35  1995 13DEC95 5216.47 30JAN95 3832.08  ; 

Define title and footnote.

 title1 'Dow Jones Yearly Highs';  footnote1 h=3 j=l ' Source: 1997 World Almanac'            j=r ' GPLDTPT1 '; 

Define symbol characteristics. SYMBOL1 defines the symbol that marks the data points and specifies its height and color. INTERPOL=JOIN joins the data points with straight lines.

 symbol1 color=red          interpol=join          value=dot          height=3; 

Generate the plot and modify the axis values. HAXIS= sets major tick marks for the horizontal axis. VAXIS= sets major tick marks for the vertical axis. HMINOR= and VMINOR= specify the number of tick marks between major tick marks.

 proc gplot data=stocks;     plot high*year / haxis=1955 to 1995 by 5                      vaxis=0 to 6000 by 1000                      hminor=3                      vminor=1 

Add reference lines and specify colors. VREF= draws reference lines on the vertical axis at three marks. LVREF= specifies the line style (dashed) for the lines; CVREF= specifies blue as the line color. CAXIS= colors the axis lines and all major and minor tick marks. CTEXT= specifies red for all plot text, including axis labels and major tick mark values.

 vref=1000 3000 5000                    lvref=2                    cvref=blue                    caxis=blue                    ctext=red;  run;  quit; 

Example 6: Generating an Overlay Plot

Procedure features:

  • PLOT statement options:

    • LEGEND=

    • OVERLAY

Other features:

  • LEGEND statement

  • SYMBOL statement

Data set: STOCKS on page 1130

Sample library member: GPLOVRL1

click to expand

In this example, one PLOT statement plots both the HIGH and LOW variables against the variable YEAR using two plot requests. The OVERLAY option on the PLOT statement determines that both plot lines appear on the same graph. The other PLOT options scale the vertical axis, add a reference line to the plot, and specify the number of minor tick marks on the axes. The SYMBOL, AXIS, and LEGEND statements modify the plot symbols, axes, and legend.

Note: If the OVERLAY option were not specified, each plot request would generate a separate graph.

Set the graphics environment.

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

Define title and footnote.

 title1 'Dow Jones Yearly Highs and Lows';  footnote1 h=3 j=l ' Source: 1997 World Almanac'            j=r 'GPLOVRL1 '; 

Define symbol characteristics. Each SYMBOL statement specifies a color, symbol type, and size for the plot symbols, and connects the data points with a straight line. SYMBOL2 specifies a solid triangle as the plot symbol by combining FONT=MARKER with VALUE=C.

 symbol1 color=red          interpol=join          value=dot          height=3;  symbol2 font=marker value=C          color=blue          interpol=join          height=2; 

Define axis characteristics.

 axis1 order=(1955 to 1995 by 5) offset=(2,2)        label=none        major=(height=2) minor=(height=1)        width=3;  axis2 order=(0 to 6000 by 1000) offset=(0,0)        label=none        major=(height=2) minor=(height=1)        width=3; 

Define legend characteristics. LABEL= suppresses the legend label. SHAPE= specifies a width and height for legend values. POSITION= centers the legend inside the top of the axis frame. MODE= shares the legend area with other graphics elements.

 legend1 label=none          shape=symbol(4,2)          position=(top center inside)          mode=share; 

Generate two plots and display them on the same set of axes. OVERLAY specifies that both plot lines appear on the same graph. LEGEND= assigns the LEGEND1 definition to the graph.

 proc gplot data=stocks;     plot high*year low*year / overlay legend=legend1                               vref=1000 to 5000 by 1000 lvref=2                               haxis=axis1 hminor=4                               vaxis=axis2 vminor=1;  run;  quit; 

Example 7: Filling Areas in an Overlay Plot

Procedure features:

  • PLOT statement options:

    • AREAS=

    • OVERLAY

Other features:

  • GOPTIONS statement

  • SYMBOL statement

Data set: STOCKS on page 1130

Sample library member: GPLFILL1

click to expand

This example uses the AREAS= option in the PLOT statement to fill the areas that are under the plot lines. As in the previous example, two plots are overlaid on the same graph.

Set the graphics environment. COLORS= sets the area colors. CTEXT= sets the color for all text.

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

Define title and footnote.

 title1 'Dow Jones Yearly Highs and Lows';  footnote1 h=3 j=l ' Source: 1997 World Almanac'            j=r 'GPLFILL1 '; 

Define symbol characteristics. INTERPOL= specifies a line to connect data points. The line creates the fill boundary.

 symbol1 interpol=join; 

Define axis characteristics.

 axis1 order=(1955 to 1995 by 5) offset=(2,2)        label=none        major=(height=2)        minor=(height=1);  axis2 order=(0 to 6000 by 1000) offset=(0,0)        label=none        major=(height=2)        minor=(height=1); 

Generate a plot with filled areas. The plot requests are ordered to draw the lowest plot first. Area 1 occupies the space between the lowest (first) plot line and the horizontal axis, and area 2 is below the highest (second) plot line. This arrangement prevents the pattern for area 1 from overlaying the pattern for area 2. AREAS=2 fills all the areas below the second plot line.

 proc gplot data=stocks;     plot low*year high*year / overlay                               haxis=axis1                               hminor=4                               vaxis=axis2                               vminor=1                               caxis=black                               areas=2;  run;  quit; 

Example 8: Plotting Three Variables

Procedure features:

  • PLOT classification variable

Other features:

  • AXIS statement

  • SYMBOL statement

  • RUN-group processing

Sample library member: GPLVRBL2

click to expand

This example shows that when your data contain a classification variable that groups the data, you can use a plot request of the form y-variable * x-variable = third-variable to generate a separate plot for every formatted value of the classification variable, which in this case is CITY. With this type of request, all plots are drawn on the same graph and a legend is automatically produced and explains the values of third-variable . The default legend uses the variable name CITY for the legend label and the variable values for the legend value descriptions. Because no LEGEND definition is used in this example, the font and height of the legend label and the legend value descriptions are set by the graphics options FTEXT= and HTEXT=. Height specifications in the SYMBOL statement do not affect the size of the symbols in the legend values.

This example then modifies the plot request. As shown in the following output, the plot is enhanced by using different symbol definitions for each plot line, changing axes labels, and scaling the vertical axes differently.

click to expand

Set the graphics environment.

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

Create the data set. CITYTEMP contains the average monthly temperatures of three cities: Raleigh, Minneapolis, and Phoenix.

 data citytemp;     input month faren city $;     datalines;     1      40.5   Raleigh     1      12.2   Minn     1      52.1   Phoenix    more data lines    12      41.2   Raleigh    12      18.6   Minn    12      52.5   Phoenix  ; 

Define title and footnote.

 title1 'Average Monthly Temperature';  footnote1 j=l ' Source: 1984 American Express';  footnote2 j=l '            Appointment Book'            j=r 'GPLVRBL2(a) '; 

Define symbol characteristics. This statement specifies that a straight line connect data points, and that the data points be represented by a 3-unit-high dot. Because no color is specified, the default color behavior is used and each line is a different color.

 symbol1 interpol=join          value=dot          height=3; 

Generate a plot of three variables. The plot request draws one plot on the graph for each value of CITY and produces a legend that defines CITY values.

 proc gplot data=citytemp;     plot faren*month=city / hminor=0;  run; 

Modify FOOTNOTE2 to reference new output.

 footnote2 j=l '         Appointment Book'            j=r 'GPLVRBL2(b) '; 

Define new symbol characteristics. SYMBOL statements are assigned to the values of CITY in alphabetical order. For example, the value Minn is assigned SYMBOL1.

 symbol1 color=green interpol=spline          width=2 value=triangle          height=3;  symbol2 color=blue interpol=spline          width=2 value=circle          height=3;  symbol3 color=red interpol=spline          width=2 value=square          height=3; 

Define new axis characteristics. AXIS1 suppresses the axis label and specifies month abbreviations for the major tick mark labels. AXIS2 specifies a two-line axis label and scales the axis to show major tick marks at every 10 degrees from 0 to 100 degrees.

 axis1 label=none        value=('JAN' 'FEB' 'MAR' 'APR' 'MAY' 'JUN'               'JUL' 'AUG' 'SEP' 'OCT' 'NOV' 'DEC')         order = 1 to 12 by 1         offset=(2)        width=3;  axis2 label=('Degrees' justify=right 'Fahrenheit')        order=(0 to 100 by 10)        width=3; 

Enhance the legend.

 legend1 label=none value=(tick=1 'Minneapolis'); 

Generate the enhanced plot. Because the procedure supports RUN-group processing, you do not have to repeat the PROC GPLOT statement to generate the second plot.

 plot faren*month=city / haxis=axis1 hminor=0                             vaxis=axis2 vminor=1                             caxis=red legend=legend1;  run;  quit; 

Example 9: Plotting with Different Scales of Values

Procedure features:

  • PLOT statement options:

    • HAXIS=

    • HMINOR=

  • PLOT and PLOT2 statement options:

    • CAXIS=

    • VAXIS=

    • VMINOR=

Other features:

  • AXIS statement

  • SYMBOL statement

Sample library member: GPLSCVL1

click to expand

This example shows how a PLOT2 statement generates a right axis that displays the values of the vertical coordinates in a different scale from the scale that is used for the left axis.

In this plot of the average monthly temperature for Minneapolis, temperature variables that represent degrees centigrade (displayed on the left axis) and degrees Fahrenheit (displayed on the right axis) are plotted against the variable MONTH. Although the procedure produces two sets of data points, it calibrates the axes so that the data points are identical and it displays only one plot.

This example uses SYMBOL statements to define symbol definitions. By default, the SYMBOL1 statement is assigned to the plot that is generated by the PLOT statement, and SYMBOL2 is assigned to the plot generated by the PLOT2 statement.

Set the graphics environment.

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

Create the data set and calculate centigrade temperatures. MINNTEMP contains average monthly temperatures for Minneapolis.

 data minntemp;     input @10 month           @23 f2;     c2=(f2-32)/1.8;     output;     datalines;  01JAN83  1    1   40.5  12.2  52.1  01FEB83  2    1   42.2  16.5  55.1    more data lines    01NOV83  11   4   50.0  32.4  59.8  01DEC83  12   1   41.2  18.6  52.5  ; 

Define title and footnote.

 title1 'Average Monthly Temperature for Minneapolis';  footnote1 j=l ' Source: 1984 American Express';  footnote2 j=l '           Appointment Book'            j=r 'GPLSCVL1 '; 

Define symbol characteristics. INTERPOL=NEEDLE generates a horizontal reference line at zero on the left axis and draws vertical lines from the data points to the reference line. CI= specifies the color of the interpolation line and CV= specifies the color of the plot symbol.

 symbol1 interpol=needle          ci=blue          cv=red          width=3          value=star          height=3; 

Define symbol characteristics for PLOT2. SYMBOL2 suppresses interpolation lines and plotting symbols; otherwise , they would overlay the lines or symbols displayed by SYMBOL1.

 symbol2 interpol=none          value=none; 

Define axis characteristics. In the AXIS2 and AXIS3 statements, ORDER= controls the scaling of the axes. Both axes represent exactly the same range of temperature, and the distance between the major tick marks on both axes represent an equivalent quantity of degrees (10 for centigrade and 18 for Fahrenheit).

 axis1 label=none        value=('JAN' 'FEB' 'MAR' 'APR' 'MAY' 'JUN'               'JUL' 'AUG' 'SEP' 'OCT' 'NOV' 'DEC')        offset=(2)        width=3;  axis2 label=('Degrees' justify=right ' Centigrade')        order=(-20 to 30 by 10)        width=3;  axis3 label=(h=3 'Degrees' justify=left 'Fahrenheit')        order=(-4 to 86 by 18)        width=3; 

Generate a plot with a second vertical axis. HAXIS= specifies the AXIS1 definition. VAXIS= specifies AXIS2 and AXIS3 definitions in the PLOT and PLOT2 statements. CAXIS= colors the axis lines and all major and minor tick marks. Axis labels and major tick mark values use the default color. VMINOR= specifies the number of minor tick marks for each axis.

 proc gplot data= minntemp;     plot c2*month  / caxis=red                      haxis=axis1 hminor=0                      vaxis=axis2 vminor=1;     plot2 f2*month / caxis=red                      vaxis=axis3                      vminor=1;  run;  quit; 

Example 10: Creating Plots with Drill-down for the Web

Procedure features:

  • PLOT statement options:

    • HTML=

    • HTML_LEGEND=

ODS features:

  • ODS HTML statement:

    • BODY=

    • NOGTITLE

    • PATH =

Other features:

  • BY statement

  • GOPTIONS statement

Sample library member: GPLDRIL1

This example shows how to create a plot with simple drill-down functionality for the Web. If you display the plot in a Web browser, you can select any plot point or legend symbol to display a report on monthly temperatures for the selected city.

The example explains how to use an ODS statement such as ODS HTML to generate a graph with drill-down links. It shows how to:

  • explicitly name the HTML files and direct the different types of output to different files

  • use BY-group processing with ODS, and determine the anchor names for the different pieces of output

  • use the PATH= option to specify the destination for the HTML and GIF files created by the ODS statement

  • add an HTML HREF string to a data set to define a link target

  • assign link targets with the HTML= and HTML_LEGEND= procedure options

  • suppress the titles in the GIF files and display them in the HTML file.

For more information on drill-down graphs, see Adding Drill-Down Links to Web Presentations on page 571.

This program modifies the code from sample GPLVRBL2, which shows how to generate separate plots for the formatted values of a classification variable. In this example, the code implements drill-down capability for the plot, enabling you to select any plot point or legend symbol to drill down to a report on the yearly temperatures for the corresponding city. The following figure shows the drill-down plot as it is viewed in a Browser.

click to expand

The following figure shows the report that appears when you select any plot point or legend symbol that corresponds to the data for Raleigh.

click to expand

Assign the fileref to the Web-server path. FILENAME assigns the fileref ODSOUT, which specifies a destination for the HTML and GIF files produced by the example program. ODSOUT must point to a Web-server location if procedure output is to be viewed on the Web. Later in the program, PATH=ODSOUT is specified on the ODS HTML statement, which directs program output to that location.

 filename odsout 'path to Web server space'; 

Close the ODS listing destination for output. To conserve system resources, use ODS LISTING to close the Listing destination for procedure output. Thus, the graphics output is not displayed in the GRAPH window, although it is written to the catalog.

 ods listing close; 

Assign graphics options for producing the ODS output. DEVICE=GIF causes ODS to generate the graphics output as GIF files. TRANSPARENCY causes the graphics output to use the Web-page background as the background of the graph. NOBORDER suppresses the border around the graphics output area, which makes the border treatment the same as that for the non-graphics output that is generated by the example.

 goptions reset=global gunit=pct           colors=(black red blue green)           ftext=swiss ftitle=swissb htitle=6 htext=3           device=gif transparency noborder; 

Open the HTML destination. PATH= specifies the ODSOUT fileref as the HTML destination for all the HTML and GIF files produced by the program. BODY= names the HTML file for storing the drill-down plot. NOGTITLE suppresses the graph title from the SAS/GRAPH output and displays it through the HTML page. ODS automatically assigns anchor names to each piece of output that is generated while the HTML destination is open.

 ods html path=odsout           body='city_plots.html'           nogtitle; 

Create the data set CITYTEMP. CITYTEMP contains the average monthly temperatures for three cities.

 data citytemp;        input  Month Fahrenheit City $;        datalines;        1      40.5    Raleigh        1      12.2    Minn        1      52.1    Phoenix        2      42.2    Raleigh        2      16.5    Minn        2      55.1    Phoenix        3      49.2    Raleigh        3      28.3    Minn        3      59.7    Phoenix        4      59.5    Raleigh        4      45.1    Minn        4      67.7    Phoenix        5      67.4    Raleigh        5      57.1    Minn        5      76.3    Phoenix        6      74.4    Raleigh        6      66.9    Minn        6      84.6    Phoenix        7      77.5    Raleigh        7      71.9    Minn        7      91.2    Phoenix        8      76.5    Raleigh        8      70.2    Minn        8      89.1    Phoenix        9      70.6    Raleigh        9      60.0    Minn        9      83.8    Phoenix       10      60.2    Raleigh       10      50.0    Minn       10      72.2    Phoenix       11      50.0    Raleigh       11      32.4    Minn       11      59.8    Phoenix       12      41.2    Raleigh       12      18.6    Minn       12      52.5    Phoenix      ; 

Add the HTML variable to CITYTEMP and create the NEWTEMP data set. The HTML variable CITYDRILL contains the target locations to associate with the different values of the variable CITY. Each location for CITYDRILL references the file city_reports.html, which this program will create. Each location ends with the default anchor name (IDX1, IDX2, and IDX3) that ODS assigns to the target output when it creates that output in file city_reports.html.

 data newtemp;     set citytemp;     length citydrill $ 40;     if city='Minn' then        citydrill='HREF="city_reports.html#IDX1"';     else if city='Phoenix' then        citydrill='HREF="city_reports.html#IDX2"';     else if city='Raleigh' then        citydrill='HREF="city_reports.html#IDX3"'; 

Define titles and footnotes and a symbol definition for the plots.

 title1 'Average Monthly Temperature';  footnote1 j=l h=3 ' Click a data point or legend symbol'            j=r 'GPLDRIL1 ';  symbol1 interpol=join          value=dot          height=3; 

Generate the plot. Both HTML= and HTML_LEGEND= specify CITYDRILL as the variable that contains the targets for the drill-down links. HTML= determines that each plot point will be a hot zone that links to target output, and HTML_LEGEND= determines that the legend symbols will be hot zones that link to target output. This GPLOT procedure generates the first piece of output in this program; thus, the plot receives the first default anchor name, which is IDX.

 proc gplot data=newtemp;     plot fahrenheit*month=city / hminor=0          html=citydrill          html_legend=citydrill;  run;  quit; 

Change the HTML file. BODY= opens a new HTML file for storing the reports for city temperatures. The new file is assigned the name city_reports.html, which is the file name assigned above to variable CITYDRILL as part of its target-link locations. The reports that are generated later in this program will all be written to this one HTML file.

 ods html path=odsout         body='city_reports.html'; 

Sort data set NEWTEMP in order by city.

 proc sort data=newtemp;     by city month;  run; 

Clear the footnotes, and suppress the default BY-line.

 goptions reset=footnote;  option nobyline; 

Print a report of monthly temperatures for each city. The BY statement determines that a separate report is generated for each city. Thus, the REPORT procedure generates three pieces of output. To assign anchor locations to this new output, ODS increments the last anchor name that was used (IDX), and therefore assigns the anchor names IDX1, IDX2, and IDX3 to the output. These are the anchor locations that were specified above as the anchor locations for variable CITYDRILL.

 title1 'Monthly Temperatures in #byval(city)';  proc report data=newtemp nowindows;    by city;    column city month fahrenheit;    define city       / noprint group;    define month      / display group;    define Fahrenheit / display group;  run; 

Close the HTML destination, and open the LISTING destination.

 ods html close;  ods listing; 



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