/* list all styles in the 'styles' directory */ proc template; list styles; run; /* show the ods path used to locate style templates */ ods path show; /* print a sample report in html, pdf, and rtf of every style located in the ods path - open styles.html in your browser */ ods listing close; proc template; define table vstyle; column libname memname style links; define links; header = 'Samples'; compute as 'HTML ' || 'PDF ' || 'RTF'; end; end; run; * Print index of all styles; ods html file="styles.html"; data _null_; set sashelp.vstyle; file print ods=(template='vstyle'); put _ods_; run; ods html close; %macro generateods(); ods html file="&style..html" style=&style; ods pdf file="&style..pdf" style=&style; ods rtf file="&style..rtf" style=&style; proc contents data=sashelp.class; run; ods rtf close; ods pdf close; ods html close; %mend; * Print a sample of each style; data _null_; set sashelp.vstyle; call symput('style', trim(style)); call execute('%generateods'); run; ods listing; /* creating style_popup output - only works in Microsoft Internet Explorer */ ods tagsets.style_popup file='popup.html'; proc freq data=sashelp.class; run; ods tagsets.style_popup close; /* defining a simple style */ proc template; define style styles.python; style body / background = white foreground = black ; style data / font_face = Times font_size = 10pt foreground = black background = #ffffcc ; style header / font_face = 'Eurostile, Arial, sans-serif' font_size = 11pt foreground = #ffffcc background = #669933 ; style table / cellpadding = 5px cellspacing = 0px borderwidth = 1px bordercolor = black borderstyle = solid ; style systemtitle / font_face = 'Eurostile, Arial, sans-serif' font_weight = bold font_size = 18pt ; style proctitle / font_face = 'Eurostile, Arial, sans-serif' font_weight = bold font_size = 14pt ; end; run; ods html file='simple.html' style=styles.python; proc contents data=sashelp.class; run; ods html close; /* styles with proc template tables */ proc template; define table mytable; style = {bordercolor=#808080 cellspacing=0}; define header head; style = {background=#808080 foreground=white}; text 'Class Information'; end; column name sex age height weight; define column name; style = header; end; define column sex; style = header{font_style=italic}; end; end; run; ods html file='tablestyles.html'; data _null_; set sashelp.class; file print ods=(template="mytable"); put _ods_; run; ods html close; /* Proc Report styles */ data energy; length state $2; input region division state $ type expenditures @@; datalines; 1 1 ME 1 708 1 1 ME 2 379 1 1 NH 1 597 1 1 NH 2 301 1 1 VT 1 353 1 1 VT 2 188 1 1 MA 1 3264 1 1 MA 2 2498 1 1 RI 1 531 1 1 RI 2 358 1 1 CT 1 2024 1 1 CT 2 1405 1 2 NY 1 8786 1 2 NY 2 7825 1 2 NJ 1 4115 1 2 NJ 2 3558 1 2 PA 1 6478 1 2 PA 2 3695 4 3 MT 1 322 4 3 MT 2 232 4 3 ID 1 392 4 3 ID 2 298 4 3 WY 1 194 4 3 WY 2 184 4 3 CO 1 1215 4 3 CO 2 1173 4 3 NM 1 545 4 3 NM 2 578 4 3 AZ 1 1694 4 3 AZ 2 1448 4 3 UT 1 621 4 3 UT 2 438 4 3 NV 1 493 4 3 NV 2 378 4 4 WA 1 1680 4 4 WA 2 1122 4 4 OR 1 1014 4 4 OR 2 756 4 4 CA 1 10643 4 4 CA 2 10114 4 4 AK 1 349 4 4 AK 2 329 4 4 HI 1 273 4 4 HI 2 298 ; proc format; value regfmt 1='Northeast' 2='South' 3='Midwest' 4='West'; value divfmt 1='New England' 2='Middle Atlantic' 3='Mountain' 4='Pacific'; value usetype 1='Residential Customers' 2='Business Customers'; run; ods html file="reportstyles.html"; proc report data=energy headline headskip nowd; column region division type expenditures; define region / order format=regfmt. 'Region' style(column)={background=#f0f0f0 color=blue} style(header)={background=#d0d0d0 color=darkblue}; define division / order format=divfmt. 'Division' style(column)={background=#e4e4e4 color=maroon} style(header)={background=#d0d0d0 color=darkblue}; define type / order format=usetype. 'Type of Customer' style(column)={background=#dadada color=teal} style(header)={background=#d0d0d0 color=darkblue}; define expenditures / sum width=12 format=dollar12.2 'Expenditures' style(column)={color=darkblue} style(header)={background=#d0d0d0 color=darkblue}; compute expenditures; bg + 1; if mod(bg, 2) = 1 then call define(_col_, "style", "style={background=#d0d0d0}"); else call define(_col_, "style", "style={background=#e4e4e4}"); endcomp; compute after / style={background=#dadada color=maroon font_weight=bold font_size=5}; line 'Total expenditures: ' expenditures.sum dollar12.2; endcomp; run; ods html close; /* Proc Tabulate styles */ ods html body="tabulatestyles.html"; data; input region $ citysize $ pop product $ saletype $ quantity amount; cards; NC S 25000 A100 R 150 3750.00 NE S 37000 A100 R 200 5000.00 SO S 48000 A100 R 410 10250.00 WE S 32000 A100 R 180 4500.00 NC M 125000 A100 R 350 8750.00 NE M 237000 A100 R 600 15000.00 SO M 348000 A100 R 710 17750.00 WE M 432000 A100 R 780 19500.00 NE L 837000 A100 R 800 20000.00 SO L 748000 A100 R 760 19000.00 WE L 932000 A100 R 880 22000.00 NC S 25000 A100 W 150 3000.00 NE S 37000 A100 W 200 4000.00 WE S 32000 A100 W 180 3600.00 NC M 125000 A100 W 350 7000.00 NE M 237000 A100 W 600 12000.00 SO M 348000 A100 W 710 14200.00 WE M 432000 A100 W 780 15600.00 NC L 625000 A100 W 750 15000.00 NE L 837000 A100 W 800 16000.00 SO L 748000 A100 W 760 15200.00 WE L 932000 A100 W 880 17600.00 NC S 25000 A200 R 165 4125.00 NE S 37000 A200 R 215 5375.00 SO S 48000 A200 R 425 10425.00 WE S 32000 A200 R 195 4875.00 NC M 125000 A200 R 365 9125.00 NE M 237000 A200 R 615 15375.00 SO M 348000 A200 R 725 19125.00 WE M 432000 A200 R 795 19875.00 NE L 837000 A200 R 815 20375.00 SO L 748000 A200 R 775 19375.00 WE L 932000 A200 R 895 22375.00 NC S 25000 A200 W 165 3300.00 NE S 37000 A200 W 215 4300.00 WE S 32000 A200 W 195 3900.00 NC M 125000 A200 W 365 7300.00 NE M 237000 A200 W 615 12300.00 SO M 348000 A200 W 725 14500.00 WE M 432000 A200 W 795 15900.00 NC L 625000 A200 W 765 15300.00 NE L 837000 A200 W 815 16300.00 SO L 748000 A200 W 775 15500.00 WE L 932000 A200 W 895 17900.00 NC S 25000 A300 R 157 3925.00 NE S 37000 A300 R 208 5200.00 SO S 48000 A300 R 419 10475.00 WE S 32000 A300 R 186 4650.00 NC M 125000 A300 R 351 8725.00 NE M 237000 A300 R 610 15250.00 SO M 348000 A300 R 714 17850.00 WE M 432000 A300 R 785 19625.00 NE L 837000 A300 R 806 20150.00 SO L 748000 A300 R 768 19200.00 WE L 932000 A300 R 880 22000.00 NC S 25000 A300 W 157 3140.00 NE S 37000 A300 W 208 4160.00 WE S 32000 A300 W 186 3720.00 NC M 125000 A300 W 351 7020.00 NE M 237000 A300 W 610 12200.00 SO M 348000 A300 W 714 14280.00 WE M 432000 A300 W 785 15700.00 NC L 625000 A300 W 757 15140.00 NE L 837000 A300 W 806 16120.00 SO L 748000 A300 W 768 15360.00 WE L 932000 A300 W 880 17600.00 proc format; value $salefmt 'R'='Retail' 'W'='Wholesale'; proc tabulate s={foreground=green}; class region citysize saletype / style={foreground=blue}; classlev region citysize saletype / style={foreground=yellow}; var quantity amount / style={foreground=black}; keyword all sum / style={foreground=white}; format saletype $salefmt.; label region="Region" citysize="Citysize" saletype="Saletype"; label quantity="Quantity" amount="Amount"; keylabel all="Total"; table all={label = "All Products" style={foreground=orange}}, (region all)*(citysize all*{style={foreground=CX002288}}), (saletype all)*(quantity*f=COMMA6. amount*f=dollar10.) / style={background=red} misstext={label="Missing" style={foreground=brown}} box={label="Region by Citysize by Saletype" style={foreground=purple}}; run; ods html close; /* Proc Print styles */ ods html body='printstyles.html'; proc format; value hgt low-60='purple' 60<-high='orange'; run; proc sort data=sashelp.class out=class; by sex; run; proc print data=class noobs n='By-group total=' 'Total Observations=' style(report)={frame=box rules=groups} style(n)={foreground=red} style(bysumline)={background=white foreground=blue} style(grandtotal)={background=white foreground=green} style(header)={font_style=italic background=yellow}; by sex; sum height; var name / style(data)={font_face=arial font_weight=bold}; var age / style(data)={font_style=italic}; var height / style(data)={foreground=hgt.}; run; ods html close; /* Traffic Lighting */ proc format; value heights 0 -< 58 = 'red' 58 -< 65 = 'yellow' 65 - HIGH = 'green'; value weights 0 -< 85 = 'very light blue' 85 -< 125 = 'light blue' 125 - HIGH = 'purple'; run; ods html file="traffic.html"; title 'Using Formats for Attribute Values'; title2 'Proc Template'; proc template; define table mytable; column name sex age height weight; define column height; style={background=heights.}; end; define column weight; style={background=weights.}; end; end; end; data _null_; set sashelp.class; file print ods=(template='mytable'); put _ods_; run; title2 'Proc Print'; proc print data=sashelp.class; var name sex age; var height / style(column)={background=heights.}; var weight / style(column)={background=weights.}; run; title2 'Proc Report'; proc report data=sashelp.class; column name sex age height weight; define height / style(column)={background=heights.}; define weight / style(column)={background=weights.}; run; title2 'Proc Tabulate'; proc tabulate data=sashelp.class; class sex age; var height weight; table age all, mean*(height*{style={background=heights.}} weight*{style={background=weights.}})*(sex all); run; ods html close; /* Alternating row colors in Proc Report */ ods html file="altcolor.html"; proc report nowd data=sashelp.class style(header)=[background=#f0f0f0 foreground=black vjust=bottom]; col name age sex height weight; compute name; bg + 1; if mod(bg, 2) = 1 then call define(_row_, "style", "style={background=white}"); else call define(_row_, "style", "style={background=#d1e9d1}"); endcomp; run; ods html close;