Скачать презентацию Behind the Scenes with SAS Using Customer Graphics Скачать презентацию Behind the Scenes with SAS Using Customer Graphics

7831c7b4f817f35d39ab036506b3300d.ppt

  • Количество слайдов: 34

Behind the Scenes with SAS®: Using Customer Graphics in SAS® Output Louise Hadden Abt Behind the Scenes with SAS®: Using Customer Graphics in SAS® Output Louise Hadden Abt Associates Inc.

Introduction SAS® provides many opportunities to add customized images to SAS ODS output. This Introduction SAS® provides many opportunities to add customized images to SAS ODS output. This presentation will demonstrate: adding custom backgrounds to tabular and graphic output; adding custom images to titles, footnotes, ODS text fields and tabular output; adding custom "fills" to SAS/GRAPH maps and graphs; Adding custom annotations to ODS GRAPHICS. 2

Introduction 3 Introduction 3

Modifying a Style Template There’s no reason to reinvent the wheel when creating a Modifying a Style Template There’s no reason to reinvent the wheel when creating a style template. SAS provides a number of style templates which can be used as the “parent” for a new style. proc template; define styles. usariem; parent=styles. minimal; replace graphbackground / background=colors('docbg') backgroundimage='rippleflag. jpg' ; end; run; 4

Modifying a Style Template 5 Modifying a Style Template 5

Images as Graph Backgrounds SAS/GRAPH procedures that produce an image, such as GCHART and Images as Graph Backgrounds SAS/GRAPH procedures that produce an image, such as GCHART and GMAP, allow the placement of custom images in the graph’s background area. goptions iback=’external image file’ imagestyle=fit; /* or tile (tile is default)*/ Check the SAS documentation for information on what types of images work with which ODS destinations! Make sure your images “fit” your graph so that you don’t get poor quality or “stretched” images in your graph background. 6

Images as Graph Backgrounds goptions reset=all xpixels=900 ypixels=750 device=jpeg ftext="Arial/bo" cback=vpag; goptions border iback='canyon 1. jpg' imagestyle=fit htitle=2. 75 htext=1. 3; ods listing close; ods html path=odsout body='tryit. htm' ; Title h=2 font=Arial bold italic 'Admissions by Zipcode - Southern Nevada'; proc gmap data=clark map=clark ; id zip; choro count_adm / coutline=black annotate=labels_clark name="tryit"; run; ods html close; ods listing; 7

Images as Graph Backgrounds 8 Images as Graph Backgrounds 8

Images in the Images in the "Backplane" Placing an image on a backplane, or “frame”, works with the GCHART, GPLOT, GRADAR, and GSLIDE procedures. The syntax is to place the “iframe” option on the procedure that generates the graph. “iframe” can refer to a fully qualified image name or a file reference (fileref. ) The default is to tile the image to fit the backplane. You must specify “imagestyle=fit” to stretch the image to fit in the backplane. 9

Images in the Images in the "Backplane" options orientation=landscape; goptions reset=all hsize=5 vsize=4 transparency border; ods html file='trylayout. htm' device=png ; proc gplot data=anal; plot v 16_a*wt_lbs / iframe=aa imagestyle=fit; run; ods _all_ close; 10

Images in the Images in the "Backplane" 11

Images as Patterns Custom images can be placed on twodimensional bars of graphs generated Images as Patterns Custom images can be placed on twodimensional bars of graphs generated by PROC GCHART’s VBAR and HBAR statements. They can also be placed on three-dimensional (3 D) bar graphs if the device used is ACTIVEX or ACTXIMG. Images are specified in the PATTERN statement using the IMAGE option. Pattern image=fileref; OR Pattern image=’external-image-file’; 12

Images as Patterns 2 D pattern 1 v=s image='amerdogtickpair. jpg'; pattern 2 v=s image='anibug. Images as Patterns 2 D pattern 1 v=s image='amerdogtickpair. jpg'; pattern 2 v=s image='anibug. gif'; pattern 3 v=s image='browndogpair. jpg'; axis 2 label=('') minor=none; axis 1 label=(''); . . . proc gchart data=a 2; vbar year / maxis=axis 1 raxis=axis 2 discrete type=sum sumvar=value subgroup=value coutline='black' width=15 nolegend ascending space=5 frame iframe='lonestargroup 4. jpg' imagestyle=tile; 13

Images as Patterns 14 Images as Patterns 14

Images as Patterns 3 D GOPTIONS DEVICE=actximg; pattern 1 v=s image='amerdogtickpair. jpg'; pattern 2 Images as Patterns 3 D GOPTIONS DEVICE=actximg; pattern 1 v=s image='amerdogtickpair. jpg'; pattern 2 v=s image='anibug. gif'; pattern 3 v=s image='browndogpair. jpg'; axis 2 label=('') minor=none; axis 1 label=(''); proc gchart data=a 2; vbar 3 d year / maxis=axis 1 raxis=axis 2 discrete type=sum sumvar=value subgroup=value coutline='black' width=15 nolegend ascending space=5 frame iframe='lonestargroup 4. jpg' imagestyle=tile; run; 15

Images as Patterns 16 Images as Patterns 16

Images in In-Line Styles Pre and Post images may be added to titles, table Images in In-Line Styles Pre and Post images may be added to titles, table cells, footnotes, header cells, and ODS TEXT fields via ODS ESCAPECHAR or using formats. ods escapechar="^"; ods text='^S={preimage="cmsnew. jpg"}'; 17

Images in In-Line Styles Data driven sparklines & PROC REPORT 18 Images in In-Line Styles Data driven sparklines & PROC REPORT 18

Annotated Images It is possible to annotate images onto SAS/GRAPH output. New in SAS Annotated Images It is possible to annotate images onto SAS/GRAPH output. New in SAS 9. 3, it is ALSO possible to annotate images in SG procedural output. data logo_anno; length function $ 8; xsys='3'; ysys='3'; when='a'; function='move'; x=2; y=85; output; function='image'; x=x+25. 4; y=y+14; imgpath='smallcmsx. png'; style='fit'; output; /* use style='fit' or 'tile' */ run; 19

Annotated Images /* move the graph down with a empty title statement so there Annotated Images /* move the graph down with a empty title statement so there is room for the logo */ title 1 h=15; title 2 /* h=2 */ "Figure 2. 1. Percentage of Nursing Home Residents by Sex and Year; United States, 2000 -2009"; proc gchart data=my_data anno=logo_anno; format stack_order barfmt. ; vbar year / discrete type=sum sumvar=percent subgroup=stack_order coutline=gray 55 space=2 width=8 noframe raxis=axis 1 maxis=axis 2 legend=legend 1 annotate=barlabel html=my_html des='' name="&name"; run; quit; 20

Annotated Images 21 Annotated Images 21

SAS/GRAPH GREPLAY In this example, based on one of Robert Allison’s samples, a map SAS/GRAPH GREPLAY In this example, based on one of Robert Allison’s samples, a map and bar chart are created separately, and then the bar chart is overlaid on the map using PROC GREPLAY. proc greplay nofs; igout=work. gseg; delete _all_; goptions nodisplay; 22

SAS/GRAPH GREPLAY /* 1 st map & bar chart */ title 1 height=2 SAS/GRAPH GREPLAY /* 1 st map & bar chart */ title 1 height=2 "Decline in Exclusive Breastfeeding from 0 to 5 Months"; title 2 font="arial/bo" height=2 "(based on DHS data)"; proc gmap data=work. mydata map=work. clipped_world all; id country_name; choro gnc_usd / levels=4 html=myhtmlvar 1 coutline=black nolegend des='' name='map'; run; 23

SAS/GRAPH GREPLAY pattern 1 v=s c=graydd; axis 1 label=none major=(number=5) minor=none; axis 2 label=none; SAS/GRAPH GREPLAY pattern 1 v=s c=graydd; axis 1 label=none major=(number=5) minor=none; axis 2 label=none; title h=10 pct " "; /* just to add some space at top of bar chart */ footnote h=4 pct " "; proc gchart data=work. mydata; vbar country_name / sumvar=diff 0_5 descending raxis=axis 1 maxis=axis 2 noframe caxis=graydd des='' name='bar'; run; 24

SAS/GRAPH GREPLAY goptions display; goptions border; proc greplay tc=tempcat nofs igout=work. gseg; tdef one SAS/GRAPH GREPLAY goptions display; goptions border; proc greplay tc=tempcat nofs igout=work. gseg; tdef one des='One' 1/ llx = 0 lly = 0 ulx = 0 uly = 100 urx = 100 ury = 100 lrx = 100 lry = 0 ; template = one; treplay 1: bar 1: map des='' name="&name"; run; 25

SAS/GRAPH GREPLAY 26 SAS/GRAPH GREPLAY 26

Special Fonts in SAS/GRAPH It is possible to use special font “glyphs” as markers, Special Fonts in SAS/GRAPH It is possible to use special font “glyphs” as markers, etc. in SAS/GRAPH You are encouraged to consult the section on specifying fonts in SAS/GRAPH in the 9. 3 documentation for more details. 27

Special Fonts in SAS/GRAPH axis 1 label=(font= Special Fonts in SAS/GRAPH axis 1 label=(font="Helvetica" '5 Star Ratings ' color=red font="Monotype Sorts" '48'x ) order=(0 to 30 by 5) minor=none offset=(0, 0); axis 2 label=none offset=(5, 5); symbol 1 i=join ci=red color=red font="Monotype Sorts" v='48'x height=3; title 1 c=red "Monotype Sorts " c=black "font characters"; title 2 a=-90 " "; footnote "5 Star Ratings - all values in " c=red font="Monotype Sorts" '48'x; proc gplot data=a; plot value*midpoint / vaxis=axis 1 haxis=axis 2 cframe=white des="" name="&name" ; run; 28

Special Fonts in SAS/GRAPH 29 Special Fonts in SAS/GRAPH 29

What’s next? SAS has given a lot of control to the user in ODS What’s next? SAS has given a lot of control to the user in ODS GRAPHICS and the SG PROCs. It is possible to output an editable graph with a SG PROCEDURE when running interactively. The statement below placed above an SG procedure will place an editable image in the results window. The image opens with the ODS graphics editor. ods listing sge=on; 30

What’s next? 31 What’s next? 31

Conclusion SAS and ODS provide SAS programmers with many options to include custom images Conclusion SAS and ODS provide SAS programmers with many options to include custom images and logos behind the scenes in procedural output. Among these options are custom style templates, custom graph backgrounds, custom graph backplanes, custom patterns on bar graphs, replaying graphic images, annotate and DSGI. ODS output, including ODS GRAPHICS, can be greatly enhanced by the use of these options. 32

Acknowledgements Robert Allison of SAS®, SAS/GRAPH Wizard; Scott Huntley of SAS®, ODS Printer Guru; Acknowledgements Robert Allison of SAS®, SAS/GRAPH Wizard; Scott Huntley of SAS®, ODS Printer Guru; Mike Zdeb, SAS/GRAPH® Map Expert, who truly does make mapping easy with SAS®; Cynthia Zender of SAS®; Dan Heath of SAS®; Mike Kalt of SAS® SAS and all other SAS Institute Inc. product or service names are registered trademarks or trademarks of SAS Institute Inc. in the USA and other countries. ® indicates USA registration. Other brand product names are registered trademarks or trademarks of their respective companies. 33

Contact Information Your comments and questions are valued and encouraged. Contact the author at: Contact Information Your comments and questions are valued and encouraged. Contact the author at: [email protected] com Code for any of the examples shown is available by request. 34