Examples


Example 1: Producing a Basic Bar Line Graph with Styles

Procedure Features:

  • BAR statement options:

    • SUMVAR=

    • DISCRETE

  • PLOT statement options:

    • SUMVAR=

Other Features:

  • INFORMAT statement

    FORMAT statement

    STYLE= option on the ODS statement

Sample library member: GBLSTOCK

click to expand

This example produces a basic bar line graph showing the volume and closing price for each of five days of trading activity on the New York Stock Exchange. The vertical bars indicate the volume, and the overlay plot graphs the closing price. It uses the ODS style ANALYSIS.

Set the graphics environment. Some graphics options may override style attributes, so if you are using a style, specify the minimum goptions needed by your graph.

 goptions reset=all device=activex; 

Define the odsout fileref. Specify the path of the HTML file where you want ODS to write the output.

 filename odsout 'C:\your_web_path\'; 

Open the HTML output destination and specify the ANALYSIS style.

 ods html file='gblstock.htm' path=odsout style=analysis; 

Create the data set NYSE. NYSE contains one observation for each of five workdays. Each observation includes the date, closing price, and volume.

 data nyse;          informat day date9.;          format day date5.;          input day $ high low close volume;          volume=volume/1000;  datalines;  02AUG2002 10478.76 10346.24 10426.91 1908809  03AUG2002 11042.92 10298.44 10274.65 1807543  04AUG2002 10498.22 10400.31 10456.43 1500656  05AUG2002 10694.47 10636.32 10762.98 1498403  06AUG2002 10801.12 10695.13 10759.48 1695602  ;  run; 

Define the title and footnote.

 title1 "NYSE Closing Price and Volume By Day";  footnote j=r h=2 'GBLSTOCK'; 

Produce the bar line graph. The SUMVAR= option on the BAR statement specifies the variable whose values determine the height of the bars. The DISCRETE option creates a separate midpoint for each unique value of the bar variable. The SUMVAR= option on the PLOT statement specifies the variable whose values are used to calculate the overlay plot.

 proc gbarline data=nyse;          bar day / sumvar=volume discrete;          plot / sumvar=close;          run;  quit; 

Close the ODS HTML destination. You must close the HTML destination before you can view the output with a browser.

 ods html close; 

Example 2: Calculating Weighted Statistics

Procedure Features:

  • BAR statement options:

    • AXIS=

      DESCENDING

      SUMVAR=

  • PLOT statement options:

    • ASCENDING

      AXIS=

      FREQ=

      SUMVAR=

Other Features:

  • AXIS statement

    SYMBOL statement

Sample library member: GBLWTSTA

click to expand

This example uses the FREQ= option to calculate weighted statistics for the overlay plot. During the manufacture of a metal-oxide semiconductor (MOS) capacitor , two different cleaning processes were used by two manufacturing systems that were operating in parallel. Process A used a standard cleaning solution, while Process B used a different cleaning mixture that contained less particulate matter. For five consecutive days, the causes of failure with each process were recorded.

Set the graphics environment.

 goptions reset=all gunit=pct border cback=white           ftitle=swissb ftext=swiss htitle=5           htext=2; 

Create the data set FAILURE. Each observation specifies the manufacturing process that resulted in the defect, the date, the cause of the defects, and the total number of defects for that date. Each observation also contains a variable, COST, that specifies the cost associated with that type of defect.

 data failure;     label  cause   = 'Cause of Failure' ;     input  process $ 1-9 day $ 13-19 cause $ 23-36 count 40-41;     datalines;  Process A   March 1   Contamination    15  Process A   March 1   Corrosion         2  Process A   March 1   Doping            1  Process A   March 1   Metallization     2  ...more data lines...  Process B   March 5   Metallization     0  Process B   March 5   Miscellaneous     1  Process B   March 5   Oxide Defect      8  Process B   March 5   Silicon Defect    2  ;  run;  data failure;     set failure;     if      cause='Contamination'  then cost=3.5;     else if cause='Metallization'  then cost=10;     else if cause='Oxide Defect'   then cost=10.5;     else if cause='Corrosion'      then cost=4.5;     else if cause='Doping'         then cost=3.6;     else if cause='Silicon Defect' then cost=5.4;     else                                cost=1.0;     output;  run; 

Define the title and footnote.

 title1 "The Cost of Defects";  footnote j=r h=3 'GBLWTSTA '; 

Define the labels for the axes.

 AXIS1 label=("Defects");  AXIS2 label=("Total Cost"); 

Specify the symbol, color , and symbol size to use for the overlay plot.

 symbol1 v=square c=black h=2; 

Produce the bar line graph. The SUMVAR= option on the BAR statement specifies the variable that determines the height of the bars. The SUMVAR= option on the PLOT statement specifies the plot variable. GBARLINE multiplies the value of the FREQ= variable by the value of the COUNT variable, and uses the result to determine the plot points.

 proc gbarline data=failure;     bar cause / sumvar=count                 axis=axis1                 descending;     plot / sumvar=count            freq=cost            axis=axis2            ascending;  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