Creating And Customizing Graphics Using Graph Template .

2y ago
71 Views
2 Downloads
207.11 KB
9 Pages
Last View : 1m ago
Last Download : 3m ago
Upload by : Aiyana Dorn
Transcription

PharmaSUG 2018 - Paper EP-17Creating and Customizing Graphics using Graph Template LanguageYanmei Zhang, Saihua Liu, Titania Dumas-Roberson, Grifols IncABSTRACTGraph Template Language (GTL) is a powerful language in SAS 9.4. PROC TEMPLATE in GTL cancreate customized graphs. The Graphics Template Language can also be used in conjunction withspecial DATA step features to produce graphs independently. This paper introduces the GTL with clinicaltrial examples. In addition, it provides some methods to solve problems we often meet when we creategraphs. Such as, label is too long to fit in one line, and legend is truncated, and so on. Creatingcomplicated graphs by using an annotate data set is discussed in the paper, too.INTRODUCTIONThe need for informative graphs becomes important in the clinical trial or manuscript developmentprocess. Statistical programmers and statisticians decide what kind of data should be displayed in thegraph to represent more information together. GTL provides powerful syntax for programmers to createthe graphs what they desire. Programmers have more options when they use the GTL. This paperrepresents some problems we meet and solutions for these problems when we create graphs.Specifically this paper includes how to use the ROWHEADERS block to split the long axis label and howto fix the truncated legend. In addition, it introduces how to use the annotate data set to display textabove the bar chart.STRUCTURE OF A BASIC GRAPH TEMPLATETwo basic step processes are needed to create a graph using GTL. They involve the TEMPLATE andSGRENDER procedures. The code below outlines the basic template definition.proc template;define statgraph nd;run;PROC TEMPLATE statement compiles and saves an ODS template for GRAPH. The DEFINE statementstarts the template definition block, and specifies the template type STATGRAPH and the template name.The END statement terminates the DEFINE block. The BEGINGRAPH statement starts the graphstatement block. The ENDGRAPH statement terminates the graph statement block. GTL statements areplaced inside the graph statement block.You can generate a graph from a graph template by utilizing the SGRENDER procedure. The code belowis to create the graph in the end.proc sgrender data data-source template template-name;run;These two steps above are necessary when generating the graph using the GTL.MAKING LONG AXIS LABELS FITThe label is truncated if it is too long to fit in the allotted space. SAS 9.4 user’s guide saysLABELFITTPOLICY SPLIT or the SHORTLABEL option can remedy this issue. A shortened label is1

Creating and Customizing Graphics using Graph Template Language, continueddisplayed no matter the label is. However, in clinical studies, we need long labels to express moreinformation for reviewer. LABELFITTPOLICY SPLIT does not work using SAS 9.4, but theROWHEADER block can make it possible.The SAS code below combines the steps above to generate a series figure. LABEL option in theYAXISOPTS below is too long and LABEL is truncated. Figure 1 did not display all of labels.proc template;define statgraph out;begingraph / border false designwidth 1300 designheight 500;entrytitle textattrs (size 10pt);layout lattice / columns 2 rows 1 border false opaque falsecolumngutter .25inlayout overlay/ yaxisopts ( label "Total IgG Concentration (mg/dL) for subject 1022002"labelfitpolicy split )xaxisopts (label "Actual time (hrs post start of infusion)");seriesplot x x1 y aval / name "life1" group trt break false datalabel n display all;endlayout;layout overlay/ yaxisopts (type log logopts (base 10 tickintervalstyle LOGEXPANDminorticks true viewmin 100 viewmax 10000) label " " )xaxisopts ( label "Actual time (hrs post start of infusion)");seriesplot x x1 y aval / name "life" group trt break false datalabel n display all;endlayout;sidebar;discretelegend "life" / border false;endsidebar;endlayout;endgraph;end;run;Figure 1. Serial Plot with Truncated LabelOne way to display all labels in the row axes is to add the ROWHEADERS (like below) in the PROCTEMPLATE and remove the label information from the row axes. ROWHEADERS syntax is simple. Itstarts with ROWHEADERS and ends with ENDROWHEADERS. By nesting the ENTRY statements in theGRIDDED layouts, we can have multiple lines of text split exactly where we want and in any text style thatwe desire. Without the GRIDDED layouts, only one ENTRY statement could be used per row. TheROWHEADERS code below is inserted into the above SAS code after SIDEBAR but before2

Creating and Customizing Graphics using Graph Template Language, continuedDISCRETELEGEND. Label of row axes is displayed correctly in the Figure 2. In this example, the use ofrow headers provided the desired flexibility over row axis labels.rowheaders;layout gridded/columns 2;entry “Total IgG Concentration (mg/dL)"/ textattrs Graphlabeltext rotate 90;entry "for Subject 1022002"/ textattrs Graphlabeltext rotate 90;endlayout;endrowheaders;Figure 2. Serial Plot with completed LabelAdding legend to graphLegend provides a key to the marker symbols, lines, and other data elements in a graph. PROCTEMPLATE does not automatically generate legends, but the mechanism for creating legendsis simple and flexible. There are several legend placement options: LOCATION, HALIGN andVALIGN. LOCATION determines whether the legend is drawn inside the plot wall of cell, oroutside the plot wall. LOCATION has two values, INSIDE and OUTSIDE. HALIGN determineshorizontal alignment. It has TOP, CENTER and BOTTOM values to choose from. VALIGNdetermines vertical alignment. There are three options: TOP, CENTER and BOTTOM.The code below generated the inside, top and right legend in the Figure 3. From this figure wecan see Legend is truncated. The legend is not truncated when I checked figure using PROCSGRENDER procedure. The problem is from style in the ODS PDF.proc template;define statgraph out;begingraph / border false designwidth 1500 designheight 600;layout lattice / columns 1 rows 1;layout overlay/ yaxisopts ( label "Total IgG Concentration (mg/dL)")xaxisopts (linearopts (viewmax 9 viewmin 1 tickvaluesequence (start 0end 9 increment 1)) label "Visit");seriesplot x visitn y mean /group trt name "trt" break false datalabel n3

Creating and Customizing Graphics using Graph Template Language, continueddisplay all ;discretelegend "trt"/location inside autoalign (topright bottomleft) ;endlayout;endlayout;endgraph;end;run;ods pdf file "H:\test\paper graph3.pdf" bookmarkgen Yes dpi 300 style Styles.temp;ods listing close;proc sgrender data gfinal template out ;run;ods pdf close;ods listing;Figure 3. Serial Plot with Truncated LegendI must update the style in the ODS PDF. Customizing styles and template is to avoid the truncatedlegend. The code below solved the truncated legend issue. Especially MARGINRIGHT andMARGINLEFT are set to 0.5 inches. The updated PROC TEMPLATE created Figure 4.proc template;define style Styles.temp;parent Styles.custom;style Body /marginright 0.5inmarginleft 0.5inmarginbottom 1infontfamily "Times New Roman";style GraphData1 / ContrastColor black MarkerSymbol "CircleFilled"Linestyle 1;style GraphBackground /background colors('docbg');end;run;4markersize 4px

Creating and Customizing Graphics using Graph Template Language, continuedFigure 4. Serial Plot without Truncated LegendCreating graph template with an annotate statementA bar chart is generated by the BARCHART or BARCHARTPARM statement. These statements can drawvertical or horizontal bar charts. Since figures need more information in the graph, sometimes theBARCHART statement is not enough. The text or arrow or line is needed to add into graph. ANNOTATEstatement can realize these. Annotation drawing space is DATAVALUE, the ANNOTATE statement isplaced in the BARCHART/BARCHARTPARM statement layout block in the template. In this location, theDATAVALUE values are in the context of the BARCHART/BARCHARTPARM data. To render the graphwith the annotations, the SGANNO ANNO option is included in the SGRENDER statement.The code below generated text above the bar chart in Figure 5.data anno;retain function "text" drawspace "datavalue"textfont "Arial" textsize 8width 50 wifthunit "pixel"anchor "center"discreteoffset 0.1;set test1;x1 xvar;y1 yvar 2;run;proc template;define statgraph plotfreq;begingraph / border false;layout lattice / rows 1 rowgutter 10;cell;layout overlay / xaxisopts (label "Treatments" labelattrs (size 8pt))yaxisopts (label "% of Subjects in each Treatment Group"labelattrs (size 8pt)linearopts (tickvaluesequence (start 0 end 100 increment 10)viewmin 0 viewmax 100) display (label ticks tickvalues));barchart x xvar y yvar / orient vertical;annotate;endlayout;5

Creating and Customizing Graphics using Graph Template Language, continuedendcell;endlayout;endgraph;end;run;proc sgrender data test1 template plotfreq sganno anno;run;Figure 5. Bar Chart with Annotation above BarGTL is easy to fill the bar with the different colors using the attribute map. A discrete attribute map is toassociate visual attributes to specific group values, which enables you to make plots that are consistent,regardless of the data order. The attribute maps allow you to map the data values to specific visual styleoptions. This allowed to specify all of the facilities and define the color scheme associated with that facilityfrom within the GTL. Shown below is only a subset of the code used to define the map. Adding the optionIGNORECASE True allows the map to match regardless of the case of the text, which is very handy ifyou work with inconsistent data. The DISCRETEATTRVAR statement is required for the attribute map tobe used, ATTVAR will be used as the group option on the horizontal bar to call the map, VAR is the nameof the variable where the data resides, and ATTRMAP is the name that you assigned the map. The codebelow can generate the Figure 6.proc template;define statgraph plotfreq;dynamic maxy;begingraph / border false;6

Creating and Customizing Graphics using Graph Template Language, continueddiscreteattrmap name "colors"/ignorecase true;value "1" /fillattrs (color grey) ;value "2" /fillattrs (color black );value "3" /fillattrs (color purple);value "4" /fillattrs (color red);value "5" /fillattrs (color green);value "6" /fillattrs (color blue);enddiscreteattrmap;discreteattrvar attrvar xcolor var xvar attrmap 'colors';layout lattice / rows 1 rowgutter 10;cell;layout overlay / xaxisopts (label "Treatments" labelattrs (size 8pt))yaxisopts (label "% of Subjects in each Treatment Group"labelattrs (size 8pt) linearopts (tickvaluesequence (start 0 end 100increment 10) viewmin 0 viewmax 100) display (label ticks tickvalues));barchart x xvar y yvar / group xcolor orient vertical barwidth 0.7 ;run;Figure 6. Bar Chart with Different Color for Each BarCONCLUSIONIn summary, GTL is more powerful and flexible than the PROG GPLOT and PROC SGPLOT. PROCTEMPLATE in GTL can create customized graphs. The Graphics Template Language can also be used7

Creating and Customizing Graphics using Graph Template Language, continuedin conjunction with special DATA step features to produce graphs independently. This paper is veryuseful for programmers beginning to learn to use GTL. This paper provided methods for some ofproblems programmers may meet, such as, label is too long to fit in one line, legend is truncated, etc. Inaddition, this paper introduces GTL combines with the annotated data set to create ideal graphs.REFERENCESSAS 9.4Graph Template Language User’s GuideSAS Pankhil Shah. “FILLPATTERNS in SGPLOT Graphs”. Proceedings of the PharmaSUG 2015 ng-with-Statistical-GraphicsProcedures.pdfKristen Much, Kaitlyn McConville,” Creating Sophisticated Graphics using Graph Template Language”.Proceedings of the PharmaSUG 2015 015/DV/PharmaSUG-2015-DV02.pdfRECOMMENDED READING Base SAS Procedures GuideSAS For Dummies CONTACT INFORMATIONYour comments and questions are valued and encouraged. Contact the author at:Name: Yanmei ZhangEnterprise: Grifols IncAddress: 79 TW Alexander DrCity, State ZIP: Durham, NC 27709Work Phone: 919-316-2278E-mail: Yanmei.zhang@Grifols.comWeb: http://www.grifolsusa.com/en/web/eeuu#Name: Saihua LiuEnterprise: Grifols IncAddress: 79 TW Alexander DrCity, State ZIP: Durham, NC 27709Work Phone: 919-316-2078E-mail: saihua.liu@Grifols.comWeb: http://www.grifolsusa.com/en/web/eeuu#Name: Titania Dumas-RobersonEnterprise: Grifols IncAddress: 79 TW Alexander DrCity, State ZIP: Durham, NC 27709Work Phone: 919-316-6153E-mail: Titania.Dumas-Roberson@grifols.comWeb: http://www.grifolsusa.com/en/web/eeuu#8

Creating and Customizing Graphics using Graph Template Language, continuedSAS and all other SAS Institute Inc. product or service names are registered trademarks or trademarks ofSAS Institute Inc. in the USA and other countries. indicates USA registration.Other brand and product names are trademarks of their respective companies.9

above the bar chart. STRUCTURE OF A BASIC GRAPH TEMPLATE Two basic step processes are needed to create a graph using GTL. They involve the TEMPLATE and . determines vertical alignment. There are three options: TOP, CENTER and BOTTOM. The code below generated the inside,

Related Documents:

Choosing custom touch functions 27 CUSTOMIZING INTUOS PRO 28 Customizing the pen 29 Adjusting tip feel and double-click 30 Adjusting eraser feel 31 Advanced tip and eraser pressure settings 31 Customizing tool buttons 32 Customizing the ExpressKeys 33 Customizing the Touch Ring 34 Tablet to screen mapping 35 Portion of screen area 37

SAP – Customizing Guide printed by Ahmad Rizki 1 of 341 SAP – Customizing Guide SAP Customizing - Table of Contents 1. General Setting 10 1.1. Set Countries 10 1.1.1. Define Countries 10 1.1.2. Set country–specific checks 12 1.1.3. Insert regions 13 1.2. Set Currencies 15 1.2.1. Check c

Graphics API and Graphics Pipeline Efficient Rendering and Data transfer Event Driven Programming Graphics Hardware: Goal Very fast frame rate on scenes with lots of interesting visual complexity Pioneered by Silicon Graphics, picked up by graphics chips companies (Nvidia, 3dfx, S3, ATI,.). OpenGL library was designed for this .

Contents vi VPN Client Administrator Guide OL-5492-01 CHAPTER 7 Customizing the VPN Client Software 7-1 Customizing the VPN Client GUI for Windows 7-2 Areas Affected by Customizing the VPN Client 7-2 Installation Bitmap 7-2 Program Menu Titles and Text 7-3 VPN Client 7-4 Setup Bitmap—setup.bmp 7-5 Creating the oem.ini File 7-5 Sample oem.ini File 7

Cisco IP Phone 7960G and 7940G v Customizing Phone Settings 36 Adjusting the Volume 36 Customizing Rings and Message Indicators 37 Customizing the Phone Screen 37 Setting Up Speed Dial Features 38 Using Voice Messaging, Call Logs, and Directories 39 Accessing Voice Messages 39 Using Call Logs and Directories 40 Accessin

Evolution of ODS Graphics Early Development of SAS Graphics In the beginning SAS had a less than stellar reputation regarding graphics output. PROC PLOT produced crude raster graphics using a line printer. Then there was SAS/GRAPH and visuals became better. Vector graphics used to produce quality output. Lots of options but too many to learn well (difficult to use “on the fly”).

"Handycam" User Guide Search Print Operation Search Before use Getting started Recording Playback Playing images on a TV Saving images with an external device Customizing your camcorder Troubleshooting Maintenance and precautions PJ390E)Contents list Top page Customizing your camcorder Customizing your camcorder Using menu items Setting up .

Interactive graphics rggobi (GGobi) Link iplots Link Open GL (rgl) Link Graphics and Data Visualization in R Overview Slide 5/121. . Graphics and Data Visualization in R Graphics Environments Base Graphics Slide 16/121. Line Plot: Single Data Set plot(y[,1], type "l", lwd 2, col "blue") 2 4 6 8 10 0.2 0.4 0.6 0.8 Index