当前位置:高等教育资讯网  >  中国高校课件下载中心  >  大学文库  >  浏览文档

《实用统计软件》课程教学资源(阅读材料)Dan Bruns, Chattanooga, TN, An Introduction to the Simplicity and Power of SAS/Graph

资源类别:文库,文档格式:PDF,文档页数:19,文件大小:496.83KB,团购合买
点击下载完整版文档(PDF)

SUGI 30 Tutorials Paper 262-30 An Introduction to the Simplicity and Power of SAS/Graph Dan Bruns,Chattanooga,TN IN THE BEGINNING In today's hectic and ever increasing demand for more information faster,the graphics tools for SAS are a great way to get lots of information conveyed quickly.I have seen tremendous enhancements and improvements in the product since it was first introduced (and first leamned it)in the late 1970s.But the basic,underlying,data-driven principals (like for most SAS procedures)are still there and easy to leam.In this tutorial we will explore how a little understanding and knowledge of the basic concepts and options of SAS/Graph will get you on your way to producing all kinds of impressive and informative graphs that can be printed,imbedded in other docs,or made available to web sites. SOME BASICS There are several procedures and statements that come with the SAS/GRAPH product,but we will only cover a few of the most powerful procedures and all the global statements in order to give you a flavor of what can be done. Within each of the procedures and statements we cover there will be dozens of options,but we will cover just a few of the most powerful. SAS/GRAPH Procedures GANNO--displays graphs created by Annotate data sets. GAREABAR--enables you to produce an area bar chart showing the magnitudes of two variables for each category of data GBARLINE--produces bar line charts.Bar line charts are vertical bar charts with a plot overlay. GCHART--produces six types of charts:block charts,horizontal and vertical bar charts,pie and donut charts,and star charts.These charts graphically represent the value of a statistic calculated for one or more variables in an input SAS data set. GCONTOUR--produces plots that represent three-dimensional relationships.The colors,contours,or surface areas of a contour plot represent the values of a contour variable at each point in a plane that is formed by a dependent and an independent variable. GDEVICE--is a tool for examining and changing the parameters of the graphics device driver catalog entries used with SAS/GRAPH software. GFONT--displays new or existing fonts and creates user-generated fonts for use in SAS/GRAPH programs. GIMPORT--enables you to import into SAS/GRAPH software graphics output that is produced with other software applications,graphics output that is produced by SAS/GRAPH software,or graphics output that is produced on other machines. GMAP--produces two-dimensional(choropleth)or three-dimensional(block,prism.and surface)color maps that show variations of a variable value with respect to an area GOPTIONS--provides information about the values of graphics options and the global statement definitions that are currently in effect in your session. GPLOT--plots the values of two or more variables on a set of coordinate axes (X and Y).The coordinates of each point on the plot correspond to two variable values in an observation of the input data set GPRINT--converts a text file into graphics output that can be displayed or printed on a graphics output device. GPROJECT-processes traditional map data sets by converting spherical coordinates(longitude and latitude)into Cartesian coordinates for use by the GMAP procedure. GMAP--produces two-dimensional(choropleth)or three-dimensional(block,prism,and surface)color maps that show variations of a variable value with respect to an area. GRADAR--creates radar(or star)charts that show the relative frequency of data measures in quality control or market research problems.(The chart statistics are displayed along spokes that radiate from the center of the chart, hence the term "star"charts). GREDUCE--processes map data sets so that they can draw simpler maps with fewer boundary points. GREMOVE--combines unit areas defined in a map data set into larger unit areas by removing shared borders between the original unit areas. GREPLAY--displays and manages graphics output that is stored in SAS catalogs.The GREPLAY procedure also creates templates and color maps that you can use when you replay your graphics output. GSLIDE--is useful for creating text slides for presentations.You can overlay text slides on other graphics output with

1 Paper 262-30 An Introduction to the Simplicity and Power of SAS/Graph® Dan Bruns, Chattanooga, TN IN THE BEGINNING In today’s hectic and ever increasing demand for more information faster, the graphics tools for SAS are a great way to get lots of information conveyed quickly. I have seen tremendous enhancements and improvements in the product since it was first introduced (and first learned it) in the late 1970s. But the basic, underlying, data-driven principals (like for most SAS procedures) are still there and easy to learn. In this tutorial we will explore how a little understanding and knowledge of the basic concepts and options of SAS/Graph will get you on your way to producing all kinds of impressive and informative graphs that can be printed, imbedded in other docs, or made available to web sites. SOME BASICS There are several procedures and statements that come with the SAS/GRAPH product, but we will only cover a few of the most powerful procedures and all the global statements in order to give you a flavor of what can be done. Within each of the procedures and statements we cover there will be dozens of options, but we will cover just a few of the most powerful. SAS/GRAPH Procedures GANNO -- displays graphs created by Annotate data sets. GAREABAR -- enables you to produce an area bar chart showing the magnitudes of two variables for each category of data. GBARLINE -- produces bar line charts. Bar line charts are vertical bar charts with a plot overlay. GCHART -- produces six types of charts: block charts, horizontal and vertical bar charts, pie and donut charts, and star charts. These charts graphically represent the value of a statistic calculated for one or more variables in an input SAS data set. GCONTOUR -- produces plots that represent three-dimensional relationships. The colors, contours, or surface areas of a contour plot represent the values of a contour variable at each point in a plane that is formed by a dependent and an independent variable. GDEVICE -- is a tool for examining and changing the parameters of the graphics device driver catalog entries used with SAS/GRAPH software. GFONT -- displays new or existing fonts and creates user-generated fonts for use in SAS/GRAPH programs. GIMPORT -- enables you to import into SAS/GRAPH software graphics output that is produced with other software applications, graphics output that is produced by SAS/GRAPH software, or graphics output that is produced on other machines. GMAP -- produces two-dimensional (choropleth) or three-dimensional (block, prism, and surface) color maps that show variations of a variable value with respect to an area. GOPTIONS -- provides information about the values of graphics options and the global statement definitions that are currently in effect in your session. GPLOT -- plots the values of two or more variables on a set of coordinate axes (X and Y). The coordinates of each point on the plot correspond to two variable values in an observation of the input data set. GPRINT -- converts a text file into graphics output that can be displayed or printed on a graphics output device. GPROJECT -- processes traditional map data sets by converting spherical coordinates (longitude and latitude) into Cartesian coordinates for use by the GMAP procedure. GMAP -- produces two-dimensional (choropleth) or three-dimensional (block, prism, and surface) color maps that show variations of a variable value with respect to an area. GRADAR -- creates radar (or star) charts that show the relative frequency of data measures in quality control or market research problems. (The chart statistics are displayed along spokes that radiate from the center of the chart, hence the term “star” charts). GREDUCE -- processes map data sets so that they can draw simpler maps with fewer boundary points. GREMOVE -- combines unit areas defined in a map data set into larger unit areas by removing shared borders between the original unit areas. GREPLAY -- displays and manages graphics output that is stored in SAS catalogs. The GREPLAY procedure also creates templates and color maps that you can use when you replay your graphics output. GSLIDE -- is useful for creating text slides for presentations. You can overlay text slides on other graphics output with SUGI 30 Tutorials

SUGI 30 Tutorials the GREPLAY procedure. GTESTIT--is a diagnostic tool for testing the installation of SAS/GRAPH software and the configuration of your device. G3D-produces three-dimensional graphs that plot one vertical variable(z)for a position on a plane that is specified by two horizontal variables (x and y). MAPIMPORT--enables you to import ESRI shapefiles (spatial data formats)and process the SHP files into SAS/GRAPH traditional map data sets. SAS/GRAPH Global Statements AXIS--modifies the appearance,position,and range of values of axes in charts and plots. GOPTIONS -specifies graphics options that control the appearance of graphics elements by specifying characteristics such as default colors,fill patterns,fonts,or text height.Graphics options can also temporarily change device settings. LEGEND--modifies the appearance and position of legends generated by procedures that produce charts.plots. and maps. PATTERN-controls the color and fill of patterns that are assigned to areas in charts,maps,and plots. SYMBOL--specifies the shape and color of plot symbols as well the interpolation method for plot data.It also controls the appearance of lines in contour plots. TITLE and FOOTNOTE--add titles and footnotes to graphics output. GPLOT PROCEDURE One of the really unique features of most SAS procedures is that they are driven by the data.And that becomes even more apparent when you see the output of the SAS/GRAPH procedures.We are going to begin with the GPLOT procedure because everyone has plotted data points a graph at some point.And that is all SAS is going to do....plot a point (with an x-value and a y-value)on the graph for each observation. With the PLOT statement you request plots to be generated with sets of Y-var*X-var pairs.GPLOT and several of the graph procedures support run-group processing. proc gplot data=sashelp.shoes; plot Returns Sales run; $50.000 $40.000 $30.000 $20.000 4+ $10.000 $0 0 $200.000 $400.000 $600.000$800.000$1.000.000$1.200.000$1.400.000 Total Sa es 2

2 the GREPLAY procedure. GTESTIT -- is a diagnostic tool for testing the installation of SAS/GRAPH software and the configuration of your device. G3D -- produces three-dimensional graphs that plot one vertical variable (z) for a position on a plane that is specified by two horizontal variables (x and y). MAPIMPORT -- enables you to import ESRI shapefiles (spatial data formats) and process the SHP files into SAS/GRAPH traditional map data sets. SAS/GRAPH Global Statements AXIS -- modifies the appearance, position, and range of values of axes in charts and plots. GOPTIONS -- specifies graphics options that control the appearance of graphics elements by specifying characteristics such as default colors, fill patterns, fonts, or text height. Graphics options can also temporarily change device settings. LEGEND -- modifies the appearance and position of legends generated by procedures that produce charts, plots, and maps. PATTERN -- controls the color and fill of patterns that are assigned to areas in charts, maps, and plots. SYMBOL -- specifies the shape and color of plot symbols as well the interpolation method for plot data. It also controls the appearance of lines in contour plots. TITLE and FOOTNOTE -- add titles and footnotes to graphics output. GPLOT PROCEDURE One of the really unique features of most SAS procedures is that they are driven by the data. And that becomes even more apparent when you see the output of the SAS/GRAPH procedures. We are going to begin with the GPLOT procedure because everyone has plotted data points a graph at some point. And that is all SAS is going to do….plot a point (with an x-value and a y-value) on the graph for each observation. With the PLOT statement you request plots to be generated with sets of Y-var * X-var pairs. GPLOT and several of the graph procedures support run-group processing. proc gplot data=sashelp.shoes; plot Returns * Sales ; run; Tot al Ret urns $0 $10, 000 $20, 000 $30, 000 $40, 000 $50, 000 $60, 000 Tot al Sal es $0 $200, 000 $400, 000 $600, 000 $800, 000 $1, 000, 000 $1, 200, 000 $1, 400, 000 SUGI 30 Tutorials

SUGI 30 Tutorials where Region a器品 + in("United states", s17,000 "Eastern Europe"); s16.000 plot Returns Sales; s1500 s14,000 run; s13000 s12000 Notice the default plot symbol is a plus s11,00四 sign and black is the default color for s1a,00 most everything.But rest assured that 000 and virtually everything else about the sa 000 S7.o00 graph you are able to control.In the 000 second plot,can you tell which Region 50001 each point is from? S4 000 000 200 s1,000 0 s100000 20000 300000 9400000 $g00000 where Region in("United states", a照S s17.000 "Eastern Europe"); s16000 plot Returns Sales Region; $15000 run; s14.000 313000 12000 Using the Y*X=variable notation tells $11.000 SAS to cycle through the colors from the s10000 devices color list for each unique value of 0,000 Region.If there are more values than 58.000 colors in the list,another symbol is $7,000 $8,000 chosen and the colors cycle again.The s5000 windows display is known as the WIN 4,000 device and has 11 colors(black,red, $3000 green,blue,cyan,magenta,grey,pink, 2,000 1,000 orange,brown,and yellow). 0 TTTT TTT 100,00m s200,00D 30m000 $40m,000 s50m,000 Tota 8io Regi on ++Eactorn Brope+++uitod gates In nearly all the graphics procedures,the statement that requests a certain kind of graphic will also allow you to specify options to control and enhance the graph.To specify those options on the PLOT statement,simply follow the plot request(s)with a slash followed by the plot options you want applied to the requested plots.There are far too many to cover all of them in this tutorial,so we will mention a few of the more powerful ones. You will notice that most options in SAS/GRAPH that begin with the letter"C"will refer to a color specification,those that begin with the letter"H"will refer to a height specification,those that begin with the letter"F"will refer to a font specification,and those that begin with the letter"L"will refer to a line-type specification. When in doubt about any specification,such as a color or font,always refer the Reference Manual.Especially line- types since they are a coded value of 1 to 46(1 being solid;2-46 some form of dashes).Over time you will get more use to them and develop your favorites. where Region The CAXIS defines the color for all the axis and CTEXT in("Unites states","Eastern Europe"); defines the color for all the text on the plot.By plot Returns Sales=Region specifying the GRID option you get what are called caxis=blue reference lines at the major tick marks on the vertical ctext=red and horizontal axis and will be a dashed line and the grid same color as the axis. run; 3

3 where Region in("United States", "Eastern Europe"); plot Returns * Sales; run; Notice the default plot symbol is a plus sign and black is the default color for most everything. But rest assured that and virtually everything else about the graph you are able to control. In the second plot, can you tell which Region each point is from? where Region in("United States", "Eastern Europe"); plot Returns * Sales = Region; run; Using the Y*X=variable notation tells SAS to cycle through the colors from the devices color list for each unique value of Region. If there are more values than colors in the list, another symbol is chosen and the colors cycle again. The windows display is known as the WIN device and has 11 colors (black, red, green, blue, cyan, magenta, grey, pink, orange, brown, and yellow). Tot al Ret urns $0 $1, 000 $2, 000 $3, 000 $4, 000 $5, 000 $6, 000 $7, 000 $8, 000 $9, 000 $10, 000 $11, 000 $12, 000 $13, 000 $14, 000 $15, 000 $16, 000 $17, 000 $18, 000 Tot al Sal es $0 $100, 000 $200, 000 $300, 000 $400, 000 $500, 000 Regi on East ern Europe Uni t ed St ates Total Ret urns $0 $1,000 $2,000 $3,000 $4,000 $5,000 $6,000 $7,000 $8,000 $9,000 $10,000 $11,000 $12,000 $13,000 $14,000 $15,000 $16,000 $17,000 $18,000 Tot al Sal es $0 $100, 000 $200, 000 $300,000 $400,000 $500,000 In nearly all the graphics procedures, the statement that requests a certain kind of graphic will also allow you to specify options to control and enhance the graph. To specify those options on the PLOT statement, simply follow the plot request(s) with a slash followed by the plot options you want applied to the requested plots. There are far too many to cover all of them in this tutorial, so we will mention a few of the more powerful ones. You will notice that most options in SAS/GRAPH that begin with the letter “C” will refer to a color specification, those that begin with the letter “H” will refer to a height specification, those that begin with the letter “F” will refer to a font specification, and those that begin with the letter “L” will refer to a line-type specification. When in doubt about any specification, such as a color or font, always refer the Reference Manual. Especially line￾types since they are a coded value of 1 to 46 (1 being solid; 2-46 some form of dashes). Over time you will get more use to them and develop your favorites. where Region in("Unites States","Eastern Europe"); plot Returns * Sales=Region / caxis=blue ctext=red grid ; run; The CAXIS defines the color for all the axis and CTEXT defines the color for all the text on the plot. By specifying the GRID option you get what are called reference lines at the major tick marks on the vertical and horizontal axis and will be a dashed line and the same color as the axis. SUGI 30 Tutorials

SUGI 30 Tutorials Tat al Rturns $18.000 $17,000 $16000 $15000 $14.000 $13.000 $12,000 $11.000 $10000 $9,000 tf 58000 $7,000 6,000 + 5000 十 $4.000 + + $53000 $2,000 $1,000 0 T7 0 $100.000 $200.000 $300.000 $400.000 $500.000 Regi on +++Eastern Erope++uited gates If you need more control of the reference lines,use the AUTOHREF and AUTOVREF options to have SAS automatically generate reference lines.Then use the LHREF(line-type for horizontal ref line),LVREF(line-type for vertical ref line).CHREF (color for horizontal ref line),and CVREF (color for vertical ref line)to control the line-type and color of the reference lines. where Region in("United states", s17.000 "Eastern Europe"); s1800 plot Returns Sales=Region s15000 s14000 autohref lhref=2 s13000 chref=lime s12000 autovref lvref-5 s11.000 cvref=pink $10000 caxis=blue s8,000 ctext=red 7,000 run; 8,000 5000 ,000 3,000 2000 1,000 100.000 200000 400000

4 Regi on East ern Europe Uni t ed St at es Tot al Ret urns $0 $1, 000 $2, 000 $3, 000 $4, 000 $5, 000 $6, 000 $7, 000 $8, 000 $9, 000 $10, 000 $11, 000 $12, 000 $13, 000 $14, 000 $15, 000 $16, 000 $17, 000 $18, 000 Total Sal es $0 $100, 000 $200, 000 $300, 000 $400, 000 $500,000 If you need more control of the reference lines, use the AUTOHREF and AUTOVREF options to have SAS automatically generate reference lines. Then use the LHREF (line-type for horizontal ref line), LVREF (line-type for vertical ref line), CHREF (color for horizontal ref line), and CVREF (color for vertical ref line) to control the line-type and color of the reference lines. where Region in("United States", "Eastern Europe"); plot Returns * Sales=Region / autohref lhref=2 chref=lime autovref lvref=5 cvref=pink caxis=blue ctext=red ; run; Regi on East ern Europe Uni t ed St at es Tot al Ret urns $0 $1, 000 $2, 000 $3, 000 $4, 000 $5, 000 $6, 000 $7, 000 $8, 000 $9, 000 $10, 000 $11, 000 $12, 000 $13, 000 $14, 000 $15, 000 $16, 000 $17, 000 $18, 000 Tot al Sal es $0 $100, 000 $200, 000 $300, 000 $400, 000 $500, 000 SUGI 30 Tutorials

SUGI 30 Tutorials Another powerful option is VAXIS (and HAXIS)to specify the major tick marks of the vertical axis.If any point lies 4 beyond what you specify.it is NOT plotted-so be careful. 10000 where Region in("United States", "Eastern Europe"); plot Returns Sales=Region vaxis=0 to 15000 by 5000 5000 autohref lhref=2 chref=lime autovref lvref=5 ++ cvref-pink 我 caxis=blue ctext=red 50 雪100000 82am000 30m.000 5400000 00000 run; GLOBAL STATEMENTS Titles Using global statements gives you even MORE control of certain aspects of the graphs along with more options to further enhance the graph.Let's take a look at the TITLE statement. titlel c=darkblue h=2.5 f=swissb "SAS/Graph c=darkred h=3.0 f=swissbi "GPLOT Example"; Can you guess what the C=,H=,and F=are specifying? That's right!-Color,Height,and Font.The quoted text following the options will take on those specifications. Axis Instead of using the VAXIS option to define the vertical axis,let's code an AXIS statement (which is much more powerful)and point to it in the plot option. axisl label=(c=darkorange h=1.5 f=zapfbi j=r "Total Returns") offset=(0.2 in order=(0 to 15000 by 5000) value=(c=darkorange f=swissl); Since you can(and usually do)have more than one axis statement,you need to number them(from 1-99)just like a title statement. The LABEL=option defines the options for just the label of the axis.The J=option in the justification of the text- left(L),center(C),right(R). The ORDER=defines the range of values and major tick marks. The VALUE=define the attributes of the labeling of the axis and the tick marks. The OFFSET=defines how far from the lower left corner of the graph to start the first tick mark

5 Another powerful option is VAXIS (and HAXIS) to specify the major tick marks of the vertical axis. If any point lies beyond what you specify, it is NOT plotted—so be careful. where Region in("United States", "Eastern Europe"); plot Returns * Sales=Region / vaxis=0 to 15000 by 5000 autohref lhref=2 chref=lime autovref lvref=5 cvref=pink caxis=blue ctext=red ; run; Regi on East ern Europe Uni t ed Stat es Tot al Returns $0 $5, 000 $10, 000 $15, 000 Tot al Sal es $0 $100, 000 $200,000 $300,000 $400, 000 $500, 000 GLOBAL STATEMENTS Titles Using global statements gives you even MORE control of certain aspects of the graphs along with more options to further enhance the graph. Let’s take a look at the TITLE statement. title1 c=darkblue h=2.5 f=swissb "SAS/Graph " c=darkred h=3.0 f=swissbi "GPLOT Example"; Can you guess what the C=, H=, and F= are specifying? That’s right! – Color, Height, and Font. The quoted text following the options will take on those specifications. Axis Instead of using the VAXIS option to define the vertical axis, let’s code an AXIS statement (which is much more powerful) and point to it in the plot option. axis1 label=(c=darkorange h=1.5 f=zapfbi j=r "Total Returns") offset=(0.2 in ) order=(0 to 15000 by 5000) value=(c=darkorange f=swissl ); Since you can (and usually do) have more than one axis statement, you need to number them (from 1 – 99) just like a title statement. The LABEL= option defines the options for just the label of the axis. The J= option in the justification of the text – left(L), center(C), right(R). The ORDER= defines the range of values and major tick marks. The VALUE= define the attributes of the labeling of the axis and the tick marks. The OFFSET= defines how far from the lower left corner of the graph to start the first tick mark. SUGI 30 Tutorials

SUGI 30 Tutorials proc gplot data=sashelp.shoes; where Region in("United States","Eastern Europe"); plot Returns Sales=Region vaxis=axis1 /*vaxis=0 to 15000 by 5000*/ autohref lhref=2 chref=lime autovref lvref=5 cvref-pink caxis=blue ctext=red run; SAS/Graph GPLOT Example Total Returns $5.00 3D.000 600 $100000 s200.000 s300.000 $400000 500000 Taal Sies Reg on ++Eaen Erope+++uited gae Let's do the same thing for the horizontal axis. axis2 proc gplot data=sashelp.shoes; label=(c=darkgreen h=1.5 where Region in("United States","Eastern Europe"); f=zapfbi)】 plot Returns Sales=Region order=(0to500000by50000) vaxis=axisl haxis=axis2 value=(f=swissl autohref lhref=2 chref=lime c=darkgreen); autovref lvref=5 cvref=pink caxis=blue ctext=red run; SAS/Graph GPLOT Example Total Returns 5000 4 6000 0.0$000帕0.0020000250030.0500000050000 Total Sales 6

6 proc gplot data=sashelp.shoes; where Region in("United States", "Eastern Europe"); plot Returns * Sales=Region / vaxis=axis1 /*vaxis=0 to 15000 by 5000*/ autohref lhref=2 chref=lime autovref lvref=5 cvref=pink caxis=blue ctext=red ; run; Regi on East ern Europe Uni t ed St at es Tot al Sal es $0 $100, 000 $200, 000 $300, 000 $400, 000 $500, 000 Let’s do the same thing for the horizontal axis. axis2 label=(c=darkgreen h=1.5 f=zapfbi) order=(0 to 500000 by 50000) value=(f=swissl c=darkgreen); proc gplot data=sashelp.shoes; where Region in("United States","Eastern Europe"); plot Returns * Sales=Region / vaxis=axis1 haxis=axis2 autohref lhref=2 chref=lime autovref lvref=5 cvref=pink caxis=blue ctext=red ; run; Regi on East ern Europe Uni t ed St at es SUGI 30 Tutorials

SUGI 30 Tutorials Symbol Now let's see what we can do with those symbols(points)on the plot.By using the SYMBOL statement you can decide how it is going to look and how to join the point.By default,the points are not joined.Let's define two symbol statements for the two regions. symboll c=red h=2 v=#/*heart*/; symbol2 c=blue h=3 v=diamond I am sure you know what the C=and H=define.The VALUE=(V=)is used,instead of say the F=,to define what symbol we want.Again,see the Reference Manual for a complete list of possible option values. If we just rerun the code from earlier,GPLOT will see the new symbol definitions and use them.Simply,if the graph needs 2 symbols it will look for a symbol1 and symbol2 and use them if found.If not,defaults are used. SAS/Graph GPLOT Example Total Returns 86,000 000 , ◇ 00 0衫 Total Sales gam9 Etern Brope◇◇◇uhtadgae Let's add an INTERPOLATION=(I=)option to the symbol statements.See the Reference Manual for a complete list of possible interpolation techniques to decide which best fits your needs(if any).The WIDTH=(W=)option defines the width the line drawn through the points. symboll c=red h=2 v=#/*heart*/i=sm50s w=2; symbol2 c=blue h=3 v=diamond i=splines w=2.5; SAS/Graph GPLOT Example Total Returns 0钟种00和0200002和.03单05000钟老中钟0 Total Sales

7 Symbol Now let’s see what we can do with those symbols (points) on the plot. By using the SYMBOL statement you can decide how it is going to look and how to join the point. By default, the points are not joined. Let’s define two symbol statements for the two regions. symbol1 c=red h=2 v=# /*heart*/; symbol2 c=blue h=3 v=diamond ; I am sure you know what the C= and H= define. The VALUE=(V=) is used, instead of say the F=, to define what symbol we want. Again, see the Reference Manual for a complete list of possible option values. If we just rerun the code from earlier, GPLOT will see the new symbol definitions and use them. Simply, if the graph needs 2 symbols it will look for a symbol1 and symbol2 and use them if found. If not, defaults are used. Regi on East ern Europe Uni t ed St at es Let’s add an INTERPOLATION=(I=) option to the symbol statements. See the Reference Manual for a complete list of possible interpolation techniques to decide which best fits your needs (if any). The WIDTH=(W=) option defines the width the line drawn through the points. symbol1 c=red h=2 v=# /*heart*/ i=sm50s w=2; symbol2 c=blue h=3 v=diamond i=splines w=2.5; Regi on East ern Europe Uni t ed St at es SUGI 30 Tutorials

SUGI 30 Tutorials GCHART PROCEDURE In my humble opinion,GCHART is one of the versatile graphics procedures.It can generate several different kinds of charts which are very popular in print or on the web.Here is an example of each type using just the defaults. Horizontal Bar Chart(HBAR) 3D Horizontal Bar Chart (HBAR3D) hbar Region hbar3d Sales; SAS/Graph GChart Example SAS/Graph GChart Example 础 11 1 70 2 2例 3的 2 20 a 2 a m m76 0 am a0m 20 ORCY Vertical Bar Chart (VBAR) 3D Vertical Bar Chart (VBAR3D) vbar Sales; vbar3d Product SAS/Graph GChart Example SAS/Graph GChart Example 8 .00 140000 Taal aes Rrod Pie Chart(PIE) 3D Pie Chart (PIE3D) pie Region pie3d Product SAS/Graph GChart Example SAS/Graph QChart Example fapcd Rad an 8

8 GCHART PROCEDURE In my humble opinion, GCHART is one of the versatile graphics procedures. It can generate several different kinds of charts which are very popular in print or on the web. Here is an example of each type using just the defaults. Horizontal Bar Chart (HBAR) hbar Region ; FREQ. CUM. FREQ. PCT. CUM. PCT. 56 56 14. 18 14.18 14 70 3. 54 17.72 37 107 9. 37 27.09 32 139 8. 10 35.19 31 170 7. 85 43.04 24 194 6. 08 49.11 45 239 11. 39 60.51 54 293 13. 67 74.18 40 333 10. 13 84.30 62 395 15. 70 100.00 Regi on West ern Europe Uni t ed Stat es Sout h Amer i ca Pacific Mi ddl e East East ern Europe Central Ameri ca/Car i bbean Canada Asi a Afri ca FREQUENCY 0 10 20 30 40 50 60 70 Vertical Bar Chart (VBAR) vbar Sales; FREQUENCY 0 100 200 300 400 Tot al Sal es $ 6 0 , 0 0 0 $ 1 8 0 , 0 0 0 $ 3 0 0 , 0 0 0 $ 4 2 0 , 0 0 0 $ 5 4 0 , 0 0 0 $ 6 6 0 , 0 0 0 $ 7 8 0 , 0 0 0 $ 9 0 0 , 0 0 0 $ 1 , 0 2 0 , 0 0 0 $ 1 , 1 4 0 , 0 0 0 $ 1 , 2 6 0 , 0 0 0 Pie Chart (PIE) pie Region ; FREQUENCY of Regi on Africa 56 Asi a 14 Canada Central Amer i ca/Cari bbean 37 32 Eastern Europe 31 Mi ddl e East 24 Pacific 45 Sout h Ameri ca 54 Uni t ed States 40 Western Europe 62 3D Horizontal Bar Chart (HBAR3D) hbar3d Sales; FREQ. CUM. FREQ. PCT. CUM. PCT. 1 395 0. 25 100.00 0 394 0. 00 99.75 0 394 0. 00 99.75 0 394 0. 00 99.75 2 394 0. 51 99.75 1 392 0. 25 99.24 2 391 0. 51 98.99 10 389 2. 53 98.48 21 379 5. 32 95.95 51 358 12. 91 90.63 307 307 77. 72 77.72 Tot al Sal es $1,260,000 $1,140,000 $1,020,000 $900,000 $780,000 $660,000 $540,000 $420,000 $300,000 $180,000 $60,000 FREQUENCY 0 100 200 300 400 3D Vertical Bar Chart (VBAR3D) vbar3d Product ; FREQUENCY 0 10 20 30 40 50 60 Product B o o t M e n ' s C a s u a l M e n ' s D r e s s S a n d a l S l i p p e r S p o r t S h o e W o m e n ' s C a s u a l W o m e n ' s D r e s s 3D Pie Chart (PIE3D) pie3d Product ; FREQUENCY of Product Boot 52 Men' s Casual 45 Men' s Dress 50 Sandal 49 Sl i pper 52 Sport Shoe 51 Women' s Casual 45 Women' s Dress 51 SUGI 30 Tutorials

SUGI 30 Tutorials Block Chart(BLOCK) Donut Chart(DONUT) block Sales donut Product; SAS/Graph GChart Example SAS/Graph GChart Example BOKO-S 时acmd Notice how SAS chooses a midpoint for each bar,slice,or block.If it is a character variable,it is easy-one for each unique value of the chart variable AND in alphabetical order.BUT,if the chart variable is numeric,SAS computes the midpoints based upon the highest and lowest values of the chart variable then normally divides the range egually over six or seven bars.Generally speaking,if I refer to a bar,the same would generally apply to a pie slice or a block.In the case of our SHOES data there was one observation with a Sales value of almost double the next highest value.But the algorithm used to compute the midpoints is smart enough to account for such outliers and adjust the number of bars accordingly.We'll discuss what the size of the bars mean a little later. We will concentrate on the bar charts to illustrate some of the options,many of which can be applied to all the types. (And because my personal favorite is the VBAR3D.) Several of the options we used for GPLOT can be used as chart options.Which one below changed slightly? titlel c=darkblue h=2.5 f=swissb "SAS/Graph c=darkred h=3.0 f=swissbi "GChart Example"; proc gchart data=sashelp.shoes; vbar3d Product caxis=blue ctext=darkblue autoref lref=2 cref=lime; run; SAS/Graph GChart Example FRECLENCY 330 M M ,S o E u c. 0 E o 0 (a 0- Foduc 9

9 Block Chart (BLOCK) block Sales ; FREQUENCY BLOCK CHART $0 $200,000 $400,000 $600,000 $800, 000 $1,000, 000 $1,200, 000 Tot al Sal es 288 83 18 2 3 1 Donut Chart (DONUT) donut Product; FREQUENCY of Product Boot 52 Men' s Casual 45 Men' s Dress 50 Sandal 49 Sl i pper 52 Sport Shoe 51 Women' s Casual 45 Women' s Dress 51 Notice how SAS chooses a midpoint for each bar, slice, or block. If it is a character variable, it is easy—one for each unique value of the chart variable AND in alphabetical order. BUT, if the chart variable is numeric, SAS computes the midpoints based upon the highest and lowest values of the chart variable then normally divides the range equally over six or seven bars. Generally speaking, if I refer to a bar, the same would generally apply to a pie slice or a block. In the case of our SHOES data there was one observation with a Sales value of almost double the next highest value. But the algorithm used to compute the midpoints is smart enough to account for such outliers and adjust the number of bars accordingly. We’ll discuss what the size of the bars mean a little later. We will concentrate on the bar charts to illustrate some of the options, many of which can be applied to all the types. (And because my personal favorite is the VBAR3D.) Several of the options we used for GPLOT can be used as chart options. Which one below changed slightly? title1 c=darkblue h=2.5 f=swissb "SAS/Graph " c=darkred h=3.0 f=swissbi "GChart Example"; proc gchart data=sashelp.shoes; vbar3d Product / caxis=blue ctext=darkblue autoref lref=2 cref=lime; run; FREQUENCY 0 10 20 30 40 50 60 Product B o o t M e n ' s C a s u a l M e n ' s D r e s s S a n d a l S l i p p e r S p o r t S h o e W o m e n ' s C a s u a l W o m e n ' s D r e s s SUGI 30 Tutorials

SUGI 30 Tutorials Answer:The H and V have been dropped in the AUTOREF options because there can be on one reference line. As before,to control the axis code an AXIS statement and specify which axis to use it for in the chart options.MAXIS stands for midpoint axis whether it be on the horizontal for VBAR or on the vertical for HBAR.The SHAPE option lets you define the shape of the bar.As always,check the Reference Manual for a complete list of possible values. CFRAME lets you control the color of the frame or background behind the bars. axisl label=(c=darkgreen SAS/Graph GChart Example h=1.5 f=zapfbi) value=(f=swissb c=darkgreen h=0.75); proc gchart data=sashelp.shoes; vbar3d Product caxis=blue ctext=darkblue autoref lref=2 cref=lime maxis=axisl shape=star cframe=cyan; run; Produet So what do you think the chart option for the other axis is called?Answer:RAXIS which stand for response axis. Thus far we have taken the default for the response axis which is Frequency-a count of observations that fall within the bars midpoint.For our data,that does not seem very useful.What might you want the height of the bar to represent? Well,you have several possibilities-FREQ(the default),CFREQ(cumulative frequency).PERCENT,CPERCENT (cumulative percent),SUM,and MEAN.Simply code one of these as a chart option.If you use the SUM or MEAN option,you will also need to code the SUMVAR option to specify which variables value to take the SUM or MEAN of. axis1 label=(c=darkgreen proc gchart data=sashelp.shoes; h=1.5 f=zapfbi) vbar3d Product value=(f=swissb caxis=blue ctext=darkblue c=darkgreen h=0.70); autoref lref=2 cref=lime axis2 label=(c=darkorange sum sumvar=sales h=1.5 f=zapfbi) maxis=axisl raxis=axis2 value=(c=darkorange shape=star cframe=cyan; f=swissl) run; SAS/Graph GChart Example Total Sales s7.08370m A17583 日4 5507、243 6000000 4137.8 000000 000000 454 Product 10

10 Answer: The H and V have been dropped in the AUTOREF options because there can be on one reference line. As before, to control the axis code an AXIS statement and specify which axis to use it for in the chart options. MAXIS stands for midpoint axis whether it be on the horizontal for VBAR or on the vertical for HBAR. The SHAPE option lets you define the shape of the bar. As always, check the Reference Manual for a complete list of possible values. CFRAME lets you control the color of the frame or background behind the bars. axis1 label=(c=darkgreen h=1.5 f=zapfbi) value=(f=swissb c=darkgreen h=0.75); proc gchart data=sashelp.shoes; vbar3d Product / caxis=blue ctext=darkblue autoref lref=2 cref=lime maxis=axis1 shape=star cframe=cyan; run; FREQUENCY 0 10 20 30 40 50 60 So what do you think the chart option for the other axis is called? Answer: RAXIS which stand for response axis. Thus far we have taken the default for the response axis which is Frequency – a count of observations that fall within the bars midpoint. For our data, that does not seem very useful. What might you want the height of the bar to represent? Well, you have several possibilities – FREQ (the default), CFREQ (cumulative frequency), PERCENT, CPERCENT (cumulative percent), SUM, and MEAN. Simply code one of these as a chart option. If you use the SUM or MEAN option, you will also need to code the SUMVAR option to specify which variables value to take the SUM or MEAN of. axis1 label=(c=darkgreen h=1.5 f=zapfbi) value=(f=swissb c=darkgreen h=0.70); axis2 label=(c=darkorange h=1.5 f=zapfbi) value=(c=darkorange f=swissl) ; proc gchart data=sashelp.shoes; vbar3d Product / caxis=blue ctext=darkblue autoref lref=2 cref=lime sum sumvar=sales maxis=axis1 raxis=axis2 shape=star cframe=cyan; run; $2,350, 543 $7, 933,707 $5,507, 243 $868, 436 $6, 175, 834 $651,467 $4, 137,861 $6,226, 475 SUGI 30 Tutorials

点击下载完整版文档(PDF)VIP每日下载上限内不扣除下载券和下载次数;
按次数下载不扣除下载券;
24小时内重复下载只扣除一次;
顺序:VIP每日次数-->可用次数-->下载券;
共19页,试读已结束,阅读完整版请下载
相关文档

关于我们|帮助中心|下载说明|相关软件|意见反馈|联系我们

Copyright © 2008-现在 cucdc.com 高等教育资讯网 版权所有