The SAS Output Delivery System and reporting techniques

How to: Add Google Web Fonts to your ODS HTML output

Reply
Community Manager
Posts: 2,761

How to: Add Google Web Fonts to your ODS HTML output

Have you ever wanted to exert a little more control over the appearance of your ODS output -- but without requiring the user to install additional special fonts?  Here's a modern HTML5-ish technique:

Blog post: Adding Google Web Fonts to your SAS reports - The SAS Dummy

Sample code:

/* These snippets copied from http://www.google.com/fonts facility    */
/* Macro for HEADTEXT option, since the value cannot exceed 256 chars */
%macro ods_html_webfont;
<link href=
'http://fonts.googleapis.com/css?family=Lato:400,700'
  rel=
'stylesheet' type='text/css'>
<link href=
'http://fonts.googleapis.com/css?family=Droid+Sans:400,700'
  rel=
'stylesheet' type='text/css'>
%mend;

proc template;
 
define style webfont;
    /* for this example, inherit existing style elements from HTMLBLUE */
   
parent=styles.htmlblue;
  style header from header /
   
fontfamily="'Droid Sans', sans-serif";
 
style data, body from _self_ /
   
fontfamily="'Lato', sans-serif";
 
class titlesandfooters /
   
fontfamily="'Lato', sans-serif";
 
end;
run;

ods html (id=wf)
  
file="c:\temp\wf_test.html"(title="Web Fonts Test")
  
style=webfont
  
headtext="%ods_html_webfont";
title "A new look for my report";
proc means data=sashelp.cars;
run;
ods html (id=wf) close;

Chris

Ask a Question
Discussion stats
  • 0 replies
  • 272 views
  • 0 likes
  • 1 in conversation