Presentation is loading. Please wait.

Presentation is loading. Please wait.

ODS Graphics: Modifying Style Attributes October 21, 2015 Rocio Lopez.

Similar presentations


Presentation on theme: "ODS Graphics: Modifying Style Attributes October 21, 2015 Rocio Lopez."— Presentation transcript:

1 ODS Graphics: Modifying Style Attributes October 21, 2015 Rocio Lopez

2 Overview ODS Style SG Procedures Style – Plot options to control style – Attribute rotation patterns – Grouped data Modifying ODS style templates Take away message Future Talks

3 ODS STYLE

4 ODS Style Graphs derive their appearance from ODS style These are produced from compiled style templates

5 Default Styles Vary by ODS Destination

6 Changing the default ODS style Changing the style in the ODS destination is the easiest way to change the apperance Use the style=style-name option in any ods destination statement – ods listing style=journal; – ods pdf style=statistical; Each style template has a different combination of style elements (fonts, colors, line patterns, marker symbols, etc.)

7 Changing the default ODS style There are over 50 styles available You can see a list of available styles by submitting the following code proc template; list styles; run;

8 ODS Styles

9 PLOT OPTIONS TO CONTROL SYTLE

10 SG Plot Style Options Many SG plot statements have options that allow you to control the appearance of graph elements Default appearance is always derived from the active ODS style SG plot statement options allow changing some aspects without changing the overall style

11 Marker Attributes proc sgplot data=sashelp.class noborder; scatter x=height y=weight / markerattrs=(color=orange size=10 symbol=CircleFilled) ; run;

12 Colors Valid color-naming schemes Color-Naming SchemeDescription Example SAS color names from the SAS Registry RED SAS Color Naming System (CNS) Specify the color with lightness, saturation and hue in that order MEDIUM STRONG RED RGB Defined by the red, green, blue components CXFF0000 RGBA Same as RGB but supports transparency aFF000033 CMYK Defined by cyan, magenta, yellow and black. Equal amounts of cyan, magenta and yellow produces process black. 00FFFF00 HLS Defined in terms of hue, lightness and saturation levels H07880FF HSV or HSB Difined by hue, saturation and brightness levels V000FFFF Gray Scale Specify lightness or darkness of gray with the lightness value GRAYC0

13 Colors To view a list of colors submit the following code: proc registry list startat=“COLORNAMES”; run;

14 Marker Attributes – Symbol & Size Available symbols Default size is in pixels. Other allowed units are: cm, in, mm, pct (or %), pt (point size at 72 dots/in) – size = n

15 Line Attributes proc sgplot data=sashelp.class noborder; density age/type=normal lineattrs=(color=purple pattern=DashDotDot thickness=2) ; run;

16 Line Attributes Same color-naming schemes as markerattrs Thickness can be specified in same units mentioned for size Available line patterns

17 Fill Attributes proc sgplot data=sashelp.class noborder; vbox height/category=sex fillattrs=(color=gray transparency=0.25) ; run; 0 (opaque) to 1 (transparent)

18 Fill Patterns Available in the JOURNAL2 or JOURNAL3 styles Do not work with box plots or histograms ods listing style=journal2; proc sgplot data=sashelp.cars noborder; vbar type/stat=percent group=Origin groupdisplay=cluster; run;

19 Data Skins proc sgplot data=sashelp.class noborder; vbox height/category=sex fillattrs=(color=gray transparency=0.25) dataskin=sheen; run;

20 Data Skins

21 Text Attributes proc sgplot data=sashelp.class noborder; vbox height/category=sex nofill; inset "p = 0.16"/position=topleft textattrs=(family="Arial" weight=bold style=italic size=10pt color=red); run;

22 Text Attributes Font Family: – SAS ODS styles use TrueType system fonts – Arial and Times New Roman available – See TrueType Fonts Supplied by SAS for listTrueType Fonts Supplied by SAS

23 Style Attributes Line, marker and text attributes are also used to control other elements Some useful examples are – Box plots: outlierattrs, meanattrs, medianattrs – Scatter plots: errorbarattrs – Bar plots: outlineattrs – Axes: labelattrs, valueattrs

24 Axis Customizations proc sgplot data=sashelp.class noborder; vbox height/category=sex nofill; xaxis display=(nolabel) valueattrs=(weight=bold) values=("F" "M") valuesdisplay=("Female" "Male"); yaxis labelattrs=(weight=bold) grid; run;

25 Split Tick Mark Values proc format; value $sexf " F" ="Female|Students" "M"="Male|Students"; proc sgplot data=sashelp.class noborder; vbox height/category=sex nofill; xaxis display=(nolabel) valueattrs=(weight=bold) splitchar="|" fitpolicy=splitalways; yaxis labelattrs=(weight=bold); format sex $sexf.; run;

26 Discrete X Axis Customizations proc sgplot data=sashelp.class noborder; vbar name/ response=height; xaxis display=(nolabel) valueattrs=(weight=bold) fitpolicy=stagger; yaxis labelattrs=(weight=bold); run;

27 ATTRIBUTE ROTATION PATTERNS

28 Attribute Rotation Pattern for Default Style

29 Attribute Rotation Patterns Default rotation priority – Honors the attribute priority rotation of the active ODS style – Usually cycles through line/marker/color at the same time Color rotation priority – Cycles through the list of colors while holding the line or marker constant – ods graphics ATTRPRIORITY=COLOR; Colors, lines, symbols used vary by ODS style

30 Attribute Rotation Patterns (default style) Default rotation priorityColor rotation priority

31 GROUPED DATA

32 What happens if you add a grouping variable? proc sgplot data=sashelp.class noborder; scatter x=height y=weight / markerattrs=(color=orange size=10 symbol=CircleFilled); run;

33 Grouped Data proc sgplot data=sashelp.class noborder; scatter x=height y=weight/ group=sex markerattrs=(color=orange size=10 symbol=CircleFilled); run;

34 Grouped Data Style attributes in individual SG plot statements – do not allow lists – your choice (1) is applied to all groups Ways to control attributes for grouped data – STYLEATTRS statement – Discrete attribute maps – Modify the ODS style template

35 STYLEATTRS Statement proc sgplot data=sashelp.class noborder; styleattrs datacolors=(red blue) datasymbols=(CircleFilled SquareFilled) datacontrastcolors=(red blue) datalinepatterns=(solid ShortDash); scatter x=height y=weight/group=sex; reg x=height y=weight/group=sex; run;

36 Multiple Grouped Data Plots By default graphical attributes are selected from the rotation pattern or your specified styleattrs lists Missing groups in certain graphs or different data order can change the appearance of the plot

37 Multiple Grouped Data Plots proc sgplot data=sashelp.cars noborder; vbar type/stat=percent group=Origin groupdisplay=cluster; run; proc sgplot data=sashelp.cars noborder; where Origin ne “Asia"; vbar DriveTrain/stat=percent group=Origin groupdisplay=cluster; run;

38 Attribute Maps Enable you to assign the same properties to specific values or ranges in 1 or multple plots. Attributes are assigned based on the data value and not the position of the data in the data set Two types available – Discrete Attribute Maps – Used to assign attributes to discrete values – Range Attribute Maps – Used to assign attributes to value ranges

39 Discrete Attribute Map Used to assign attributes to discrete values Create a SAS data set with the following information: – Required Columns: – ID: Identifies the attribute map. A data set may contain >1. – VALUE: Variable associated with group value. If variable is formatted, use format value. – At least one of the following: FillColorMarkerSymbolFillStyleElement FillTransparencyMarkerTransparencyLineStyleElement LineColorTextColorMarkerStyleElement LinePatternTextFontTextStyleElement LineThicknessTextSize MarkerColorTextStyle MarkerSizeTextWeight

40 Creating the Discrete Attribute Map data myattrmap; input id $5-8 value $10-15 FillStyleElement $17-26 LineStyleElement $28-37; datalines; myid Asia GraphData1 GraphData1 myid Europe GraphData2 GraphData2 myid USA GraphData3 GraphData3 ; run; data myattrmap2; input id $5-8 value $10-15 FillColor $17-24 LineColor $26-35; datalines; myid Asia cx7C95CA cx2A25D9 myid Europe cxDE7E6F cxB2182B myid USA cx66A5A0 cx01665E ; run; =

41 Applying the Discrete Attribute Map proc sgplot data=sashelp.cars dattrmap=myattrmap noborder; vbar type/stat=percent group=Origin groupdisplay=cluster attrid=myid; run; proc sgplot data=sashelp.cars dattrmap=myattrmap noborder; where Origin ne "Asia"; vbar DriveTrain/stat=percent group=Origin groupdisplay=cluster attrid=myid; run;

42 MODIFYING ODS STYLE TEMPLATES

43 Style Templates Control appearance of tables and graphs Has elements to control all features in graph You can change certain aspects of a given template and leave all else intact or create your own

44 Obtaining the source code proc template; source styles.default; run;

45 Style Elements Affecting Template-Based Graphics See SAS documentation for full listSAS documentation

46 Modifying an Existing Style Template Requested changes – Dark blue background – White markers/lines – White font – White axes

47 Modifying an Existing Style Template proc template; define style MyListingStyle; parent=styles.listing; **control graph background (outside of axes); style GraphBackground from GraphBackground/ color = darkblue; **control graph background (within axes); style GraphWalls from GraphWalls/ color = darkblue; **control legend background; style GraphLegendBackground from GraphLegendBackground/ color = darkblue;

48 Modifying an Existing Style Template - continued **control axis lines; style GraphAxisLines from GraphAxisLines/ contrastcolor = white; **control all font colors; style GraphColors from GraphColors/ 'gtext‘ = white 'glabel‘ = white; **Control data points; style GraphDataDefault from GraphDataDefault / markersize = 10px markersymbol = "squarefilled" contrastcolor = white; **Control fit line; style GraphFit from GraphFit/ contrastcolor = white; end; run;

49 Applying the New Style Template ods listing style=mylistingstyle; proc sgplot data=sashelp.class noborder; scatter x=height y=weight; reg x=height y=weight; keylegend/noborder; run;

50 TAKE AWAY MESSAGE

51 Take away message SAS has made many advances in their graphics procedures There are several options to control style elements which makes changes easy to apply For primarily SAS users, there is no longer a need to rely on R for generating plots

52 SAS Version All examples presented have been generated using SAS 9.4. Some of the code might not run in 9.2-9.3. SAS 9.4M3 has many new style features including: – transparent backgrounds – SGPLOT options to change background color – Use of special characters (e.g. ≥, ≤, α) in labels, tick mark values or legends

53 Talk Materials All materials can be found at my SAS community user page http://www.sascommunity.org/wiki/User:Lopezrhttp://www.sascommunity.org/wiki/User:Lopezr

54 Good Resources Graphically Speaking Blog SAS Tips Sheets – Graph Style Tip Sheet Graph Style Tip Sheet – PROC TEMPLATE Styles Tip Sheet PROC TEMPLATE Styles Tip Sheet SAS Documentation: Controlling the Appearance of Your GraphsControlling the Appearance of Your Graphs

55 FUTURE TALKS

56 Future talks Introduction to Graph Template Language (GTL) (11/18/2015) Automatic ODS Graphics from SAS Procedures and How to Modify These (01/2016) Useful SAS Graphics Macros (02/2016) Step-by-step examples of some plots (03/2016)

57 QUESTIONS?

58 THANKS


Download ppt "ODS Graphics: Modifying Style Attributes October 21, 2015 Rocio Lopez."

Similar presentations


Ads by Google