160 likes | 296 Vues
Dive into the fundamental concepts of SAS/GRAPH with a focus on key procedures like GOPTIONS, GPLOT, GCHART, and G3D. This guide will walk you through creating various types of graphs, including scatter plots, bar charts, pie charts, and 3D visualizations. Learn to customize graph appearances with options for axes, symbols, and legends. Whether you are generating simple 2D plots or complex 3D surfaces, this resource provides essential instructions and examples to enhance your SAS/GRAPH skills effectively.
E N D
SAS/GRAPH The Basics
Today’s Topics • GOPTIONS • GPLOT • GCHART • GCONTOUR • G3D
Getting Started in SAS/GRAPH • GOPTIONS: • Similar to OPTION, but specific to SAS/GRAPH • Gives instructions about appearance of graphs • Applies for entire SAS session or until reset within a session • Can appear anywhere in program, but preferably within SAS/GRAPH procedure Example 5.1.1
GPLOT:Creating a Scatter Plot • Procedure GPLOT • PROC GPLOT DATA=dataset; • PLOT y*x(=z)/options; • RUN; • QUIT; Examples 5.2.1, 5.2.2
SYMBOL Statement • Controls appearance of symbols in graph • Options include: • VALUE= (V=) • INTERPOL= (I=) • COLOR= (C=) • LINE= (L=) Example 5.3.1
The OVERLAY and LEGEND options • Appear after slash (/) in PLOT statement • OVERLAY used when PLOT has more than one X or Y • OVERLAY cannot be used with form y*x=z • LEGEND option causes legend to print • Legend prints automatically with y*x=z form, but not with OVERLAY option
AXIS Statement • Controls appearance of axes • Define which axis with VAXIS= and HAXIS= options in PLOT statement • Some options available include: • LABEL= • ORDER= • VALUE= • MINOR= • MAJOR= Example 5.3.2
GCHART • Horizontal Bar Charts (2D and 3D) • Vertical Bar Charts (2D and 3D) • Pie Charts (2D and 3D) • Block Charts • Star Charts
Creating a Histogram • Use the VBAR statement • Options include: • Specifying midpoints • Changing patterns in bars Examples 5.4.1, 5.4.2
Creating Horizontal and Vertical Bar Frequency Charts • Statements are VBAR and HBAR • When data are counts, use FREQ= option Example 5.4.3
Cross-Classification in Charts • Classify bars by 2 variables instead of just one • List one variable in HBAR or VBAR statement • List second variable in GROUP= option Example 5.4.5
Plots of 3D Data • Contour plot (Y*X=Z format) • Y-variable defines y-axis • X-variable defines x-axis • Z-variable defines levels of contours • 3-D Plot (Y*X=Z format) • Y-variable defines y-axis • X-variable defines x-axis • Z-variable defines z-axis • Scatter plot or Surface plot Examples 5.6.1, 5.6.2
Contour Plots • PROC GCONTOUR • Options available include: • LEVELS: levels of contours • LLEVELS: line types of contours • HAXIS, VAXIS: same as GPLOT • HREF, VREF: draws reference lines • LEGEND: same as before
3-D Plots • PROC G3D • Surface plot: PLOT statement • Scatter plot: SCATTER statement • Options available with only the PLOT statement: • CTOP, CBOTTOM: color of top and bottom of surface • Options available with only the SCATTER statement: • SHAPE: defines shapes of symbols • COLOR: defines color of symbols
Options with PLOT or SCATTER in G3D • ROTATE: rotates graph specified # of degrees • TILT: tilts graph specified # of degrees (must be between 0 and 90) • XTICKNUM, YTICKNUM: defines # of tick marks • CAXIS: color of axes • ZMAX, ZMIN: defines min and max values for z-axis • GRID: draws grid “walls” Examples 5.6.3, 5.6.4, 5.6.5