styles PROCTemplate TEMPLATEStyles StylesTip TipSheet Sheet proc PROC PROCTEMPLATE TEMPLATEStyles StylesTip TipSheet Sheet Defining a Style Template Defining DefiningaaStyle StyleTemplate Template Basic Structure Basic Basic Structure Structure proc template; define style style-name; proc proc template; template; … statements attributes … define define style style/style-name; style-name; end; …… statements statements/ /attributes attributes …… run; end; end; run; run; Commonly Used Statements Commonly CommonlyUsed UsedStatements Statements style style-element < from parent-style-element > / style-attributes; style style style-element style-element<<from fromparent-style-element parent-style-element>>/ / Definesstyle-attributes; a style element with name style-element and style-attributes; attributes If specified, the attributes Defines Definesastyle-attributes. astyle styleelement elementwith with name namestyle-element style-element and and from parent-style-element are also included. attributes attributesstyle-attributes. style-attributes.IfIfspecified, specified,the theattributes attributes Attributes of the same nameare specified in the STYLE from fromparent-style-element parent-style-element arealso alsoincluded. included. statement will override the parent. Multiple Attributes Attributes ofofthe thesame samethose name namein specified specified ininthe the STYLE STYLE style elements can be defined by statement statement will will override override those thosesimultaneously, ininthe theparent. parent.Multiple Multiple giving aelements comma-delimited list of names in style styleelements can canbe bedefined defined simultaneously, simultaneously, by by style-element. giving givingaacomma-delimited comma-delimitedlist listofofnames namesinin style-element. style-element. class style-element / style-attributes; Defines a style element with the name style-element class classstyle-element style-element / /style-attributes; style-attributes; and parentaaof style-element. This a shortcut for Defines Defines style style element elementwith with the theis name name style-element style-element “style style-element from style-element /shortcut style- for and andparent parent ofofstyle-element. style-element. This Thisisisaashortcut for attributes;”. Multiple from style elements can /be defined “style “stylestyle-element style-element fromstyle-element style-element /stylestylesimultaneously, by giving a comma delimited list of attributes;”. attributes;”.Multiple Multiple style style elements elements can canbe bedefined defined names in style-element. simultaneously, simultaneously, by bygiving givingaacomma commadelimited delimitedlist listofof names namesininstyle-element. style-element. import “URL”; Reads a CSS file into the current style definition. import import “URL”; “URL”; URL can be either ainto local pathstyle or a location on Reads Reads aaCSS CSS file fileinto the thefile current current style definition. definition. the Internet using theaaFTP HTTP protocols. URL URL can canbe be either either local localor file file path pathor oraalocation locationon on the theInternet Internetusing usingthe theFTP FTPororHTTP HTTPprotocols. protocols. Style Definition Example Style StyleDefinition DefinitionExample Example template; Column for logo, address, and trademark info. Column Columnfor forlogo, logo,address, address,and andtrademark trademarkinfo. info. proc define style mystyle; proc proc template; template; notes "My Simple Style"; define define style style mystyle; mystyle; class body / notes notes "My "My Simple Simple Style"; Style"; backgroundcolor = white class class body body // color = black backgroundcolor backgroundcolor == white white fontfamily = "Palatino" color color == black black ; fontfamily fontfamily == "Palatino" "Palatino" class systemtitle / ;; fontfamily = "Verdana, Arial" class class systemtitle systemtitle // fontsize = 16pt fontfamily fontfamily == "Verdana, "Verdana, Arial" Arial" fontweight = bold fontsize fontsize == 16pt 16pt ; fontweight fontweight == bold bold class table / ;; backgroundcolor = #f0f0f0 class class table table // bordercolor = black backgroundcolor backgroundcolor == #f0f0f0 #f0f0f0 borderstyle = solid bordercolor bordercolor == black black borderwidth = 1pt borderstyle borderstyle == solid solid cellpadding borderwidth borderwidth===5pt 1pt 1pt cellspacing = 0pt cellpadding cellpadding == 5pt 5pt frame = void cellspacing cellspacing == 0pt 0pt rules = groups frame frame == void void ; rules rules == groups groups class header, footer / ;; backgroundcolor = #c0c0c0 class class header, header, footer footer // fontfamily = "Verdana, Arial" backgroundcolor backgroundcolor == #c0c0c0 #c0c0c0 fontweight = bold fontfamily fontfamily == "Verdana, "Verdana, Arial" Arial" ; fontweight fontweight == bold bold class data / ;; fontfamily = "Palatino" class class data data // ; fontfamily fontfamily == "Palatino" "Palatino" end; ;; run; end; end; run; run; ods pdf style=mystyle; proc report data=sashelp.class; ods ods pdf pdf style=mystyle; style=mystyle; run; proc proc report report data=sashelp.class; data=sashelp.class; ods pdf close; run; run; ods ods pdf pdf close; close; PROC PROC PROC TEMPLATE TEMPLATE TEMPLATE Styles Styles Styles Tip Sheet Tip Tip Sheet Sheet This tip sheet places frequently used information in one place, on one used sheet This Thistip tipsheet sheet places places frequently frequently used of paper, so youinin don’t have toon search through information information one oneplace, place, on one onesheet sheet ofof the online documentation. It also gives paper, paper, so soyou youdon’t don’thave have totosearch searchyou through throughthe the something to take home,ItIttype andyou try. online onlinedocumentation. documentation. also alsoin, gives gives you something somethingto totake takehome, home,type typein, in,and andtry. try. PROC TEMPLATE styles give you the power to customize the lookstyles and feel ofyou yourthe ODS PROC PROCTEMPLATE TEMPLATE styles give give you the power powerto to reports. Youthe canlook change the colors, customize customize the look and andfeel feelfonts, ofofyour your ODS ODS borders, Itcolors, is also reports. reports.and You Youadd can canimages change changeand the thetext. fonts, fonts, colors, possible toand setadd the style of and data cellsItin tables borders, borders, and addimages images andtext. text. Itisis also also based on to the data itself. tip sheet presents possible possible toset set the the style styleThis ofofdata data cells cellsinin tables tables the most common statements attributes based based on on the thedata data itself. itself.This Thisand tip tipsheet sheet presents presents used in creating styles with PROC TEMPLATE. the themost most common common statements statements and and attributes attributes used usedinincreating creatingstyles styleswith withPROC PROCTEMPLATE. TEMPLATE. Commonly Used Attributes Commonly CommonlyUsed UsedAttributes Attributes notes “text”; Specifies comments about the style definition that notes notes“text”; “text”; are stored the template. Specifies Specifieswith comments comments about aboutthe thestyle styledefinition definitionthat that are arestored storedwith withthe thetemplate. template. parent=style-definition; Specifies a style definition to inherit style elements parent=style-definition; parent=style-definition; from. Specifies Specifiesaastyle styledefinition definitiontotoinherit inheritstyle styleelements elements from. from. SAS Institute Inc. World Headquarters For complete information refer to the +1 919 677 8000 www.sas.com/offices Base SAS® 9.2 documentation at For Forcomplete completeinformation informationrefer refertotothe the http://support.sas.com/v9doc Base BaseSAS SAS 9.2 9.2documentation documentationatat http://support.sas.com/v9doc http://support.sas.com/v9doc 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 and product names are trademarks of their respective companies. Copyright © 2008, SAS Institute Inc. All rights reserved. 479398_01.08 PROC PROCTemplate TEMPLATE TEMPLATEStyles Styles StylesTip Tip TipSheet Sheet Sheet proc Terms Terms style styleattribute attribute AAname-value name-valuepair pairthat thatdescribes describesaasingle singlebehavioral behavioral or orvisual visualaspect aspectof ofaapiece pieceof ofoutput. output. style styleelement element AAnamed namedcollection collectionof ofstyle styleattributes attributesspecified specifiedby by the theSTYLE STYLEor orCLASS CLASSstatement. statement.Each Eacharea areaininaa piece pieceof ofODS ODSoutput outputhas hasaastyle styleelement elementname name associated associatedwith withititwhere wherethe theattributes attributeswill willbe be applied. applied. style style| |style styletemplate template| |style styledefinition definition All Allthree threeterms termsare arecommonly commonlyused usedtotodescribe describeaa named namedcollection collectionof ofstyle styleelements. elements.The Thestyle style definition definitionname nameisisused usedininthe theSTYLE= STYLE=option optionof ofthe the ODS ODSstatement. statement. Cascading CascadingStyle StyleSheets Sheets(CSS) (CSS) An Analternative alternativestyle stylelanguage languagetotoPROC PROCTEMPLATE TEMPLATE styles styleswritten writtenby bythe theWorld WorldWide WideWeb WebConsortium Consortium (W3C) (W3C)which whichisiscommonly commonlyused usedtotoapply applystyles stylestoto web webpages. pages.For Formore moreinformation, information,see see http://www.w3.org/Style/CSS/. http://www.w3.org/Style/CSS/. Browsing Browsing Templates Templates The Thestyle styletemplates templatessupplied suppliedby bySAS SAS®®®are arestored storedinin the theSASHELP.TMPLMST SASHELP.TMPLMSTitemstore. itemstore.You Youcan can browse browsethe thetemplates templatesusing usingeither eitheraagraphical graphical interface interfaceor orPROC PROCTEMPLATE TEMPLATEcode. code. odstemplates odstemplates Type Typeodstemplates odstemplatesinto intothe thecommand commandbar bartotoopen open the theTemplate TemplateBrowser. Browser.Double-clicking Double-clickingaatemplate template displays displaysits itssource sourcecode. code.The Thestyles stylessupplied suppliedby bySAS SAS are arelocated locatedininthe thestyles stylesdirectory directoryof ofthe the SASHELP.TMPLMST SASHELP.TMPLMSTitemstore. itemstore. proc proctemplate; template;list liststyles; styles;run; run; Lists Listsall alltemplates templatesininstyles stylesdirectory. directory.This Thisisisthe the default defaultlocation locationfor forthe thestyles stylessupplied suppliedby bySAS. SAS. proc proctemplate; template;source sourcestyle-name; style-name;run; run; Displays Displaysthe thesource sourceof ofstyle-name style-nametotothe thelog. log. Using Using aa Style Style Definition Definition The Thefollowing followingcode codeapplies appliesaastyle stylewith withthe thename name style-name style-nametotoan anODS ODSdestination. destination. ods ods ods destination destination destinationstyle=style-definition style=style-definition style=style-definition ……… ;;; All AllODS ODSdestinations destinationsexcept exceptfor fordocument, document,listing, listing, and andoutput outputsupport supportthe theSTYLE= STYLE=option. option. Using Using aa CSS CSS File File The Thefollowing followingcode codeloads loadsaaCSS CSSfile filerather ratherthan thanaa PROC PROCTEMPLATE TEMPLATEstyle. style. ods ods ods destination destination destinationcssstyle=”URL” cssstyle=”URL” cssstyle=”URL” ……… ;;; where whereURL URLisisaalocal localfile filepath pathor oraalocation locationon onthe the Internet Internetusing usingthe theFTP FTPor orHTTP HTTPprotocols. protocols. All AllODS ODSdestinations destinationsexcept exceptfor fordocument, document,listing, listing, and andoutput outputsupport supportthe theCSSSTYLE= CSSSTYLE=option. option. Style Style Attribute Attribute Values Values dimension dimension AApositive positiveinteger integeror orfloating floatingpoint pointvalue valuefollowed followed by byone oneof ofthe thefollowing followingunits: units: pt pt pt–––points points points(1/72 (1/72 (1/72inch) inch) inch) in in in–––inches inches inches cm cm cm–––centimeters centimeters centimeters(2.54 (2.54 (2.54cm cm cm===111inch) inch) inch) mm mm mm–––millimeters millimeters millimeters(25.4 (25.4 (25.4mm mm mm===111inch) inch) inch) % % %---percentage percentage percentage(percentage (percentage (percentageof of ofcurrent current currentfont font fontsize size size for for forfontsize=; fontsize=; fontsize=;percentage percentage percentageof of ofcontainer container containerwidth width width or or orheight height heightfor for forwidth= width= width=and and andheight=) height=) height=) ex ex ex–––height height heightof of ofthe the the‘x’ ‘x’ ‘x’character character character em em em–––width width widthof of ofthe the the‘m’ ‘m’ ‘m’character character character px px px–––pixels pixels pixels color-name color-name colorname. name. Any Anypredefined predefinedSAS/GRAPH SAS/GRAPH®®®color hex-color hex-color Indicates Indicatesthe thered, red,green, green,and andblue bluecomponents componentsof ofaa color color(from (from00toto255) 255)ininhexadecimal hexadecimalpreceded precededby by the the##character. character.For Forexample, example,red redisis#ff0000, #ff0000,green green isis#00ff00, #00ff00,and andblue blueisis#0000ff. #0000ff. Commonly Commonly Used Used Style Style Attributes Attributes General GeneralStyle StyleAttributes Attributes backgroundcolor=color-name backgroundcolor=color-name| |hex-color hex-color Specifies Specifiesthe thebackground backgroundcolor colorof ofaaregion. region. backgroundimage=“path-to-file” backgroundimage=“path-to-file” Specifies Specifiesan animage imagetotoput putininthe thebackground. background. color=color-name color=color-name| |hex-color hex-color Specifies Specifiesthe thecolor colorof ofthe thetext textcontent. content. height=dimension height=dimension width=dimension width=dimension Specifies Specifiesthe thewidth widthand andheight heightof ofan anelement. element. preimage=“path-to-file” preimage=“path-to-file” postimage=“path-to-file” postimage=“path-to-file” Specifies Specifiesan animage imagetotoput putbefore/after before/afterthe thecontent. content. pretext=“text” pretext=“text” posttext=“text” posttext=“text” Specifies Specifiestext texttotoput putbefore/after before/afterthe thecontent. content. Font Fontand andText TextStyle StyleAttributes Attributes fontfamily=“fontfamily-1, fontfamily=“fontfamily-1,fontfamily-2, fontfamily-2,…” …” Specifies Specifiesaalist listof offont fontfamily familyalternatives alternativesfor forthe thetext text content. content.The Thefirst firstusable usablefont fontfound foundon onthe thesystem system will willbe beused. used. fontsize=dimension fontsize=dimension Specifies Specifiesthe thesize sizeof ofthe thetext. text. fontstyle=italic fontstyle=italic| |roman roman| |slant slant Specifies Specifiesthe thestyle styleof ofthe thetext. text. fontweight=bold fontweight=bold| |medium medium Specifies Specifieswhether whetherthe thetext textshould shouldbe bebold boldor ornot. not. textdecoration=line_through textdecoration=line_through| |overline overline| | underline underline Indicates Indicatesthat thataahorizontal horizontalline lineshould shouldbe beplaced placed through, through,over, over,or orunder underthe thetext. text. Commonly Commonly Used Used Style Style Attributes Attributes (Continued) (Continued) (Continued) Table TableStyle StyleAttributes Attributes borderspacing=dimension borderspacing=dimension cellspacing=dimension cellspacing=dimension Specifies Specifiesthe theamount amountof ofspace spacetotoput putbetween between adjacent adjacenttable tablecells. cells. frame=box frame=box| |above above| |below below| |hsides hsides| |vsides vsides | |lhs lhs| |rhs rhs| |void void Specifies Specifieswhich whichborders bordersshould shouldappear appeararound aroundthe the perimeter perimeterof ofthe thetable. table. padding=dimension padding=dimension cellpadding=dimension cellpadding=dimension Specifies Specifiesthe theamount amountof ofspace spacetotoput putbetween betweenthe the content contentand andborder borderof ofthe thecells. cells. rules=all rules=all| |cols cols| |rows rows| |groups groups| |none none Specifies Specifieswhich whichborders bordersshould shouldappear appearwithin withinthe the table. table. Border BorderStyle StyleAttributes Attributes bordercolor=color-name bordercolor=color-name| |hex-color hex-color Specifies Specifiesthe thecolor colorof ofthe theborder borderon onall allsides. sides. Individual Individualborders borderscan canbe beset setusing using bordertopcolor=, bordertopcolor=,borderrightcolor=, borderrightcolor=, borderbottomcolor=, borderbottomcolor=,and andborderleftcolor=. borderleftcolor=. borderstyle=dashed borderstyle=dashed| |dotted dotted| |double double| |groove groove | |hidden hidden| |inset inset| |outset outset| |ridge ridge| |solid solid| |none none Specifies Specifiesthe thestyle styleof ofthe theborder borderon onall allsides. sides. Individual Individualborders borderscan canbe beset setusing using bordertopstyle=, bordertopstyle=,borderrightstyle=, borderrightstyle=, borderbottomstyle=, borderbottomstyle=,and andborderleftstyle=. borderleftstyle=. borderwidth=dimension borderwidth=dimension Specifies Specifiesthe thewidth widthof ofthe theborder borderon onall allsides. sides. Individual Individualborders borderscan canbe beset setusing using bordertopwidth=, bordertopwidth=,borderrightwidth=, borderrightwidth=, borderbottomwidth=, borderbottomwidth=,and andborderleftwidth=. borderleftwidth=.