BookmarkSubscribeRSS Feed
ChrisHemedinger
Community Manager

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

Check out SAS Innovate on-demand content! Watch the main stage sessions, keynotes, and over 20 technical breakout sessions!
3 REPLIES 3
HGimenez
Obsidian | Level 7

Has anybody been able to add lato to a PDF output in ODS?

 

So far, I tried downloading the .ttf and executing this code

proc fontreg mode=add;
fontpath 'Z:\lato';
run;

ODS PDF FILE='c:\temp\1.pdf';

PROC REPORT
		STYLE(COLUMN)={font_face='Lato'}
		DATA=SASHELP.CLASS
		;
	RUN;

ODS PDF CLOSE;

 

any ideas?? Thanks a lot!! 

ChrisHemedinger
Community Manager

@HGimenez On Windows, I suspect that you need to have the font installed.  If you right-click on the ttf file, you should have the option to install it into your Windows font directory.

 

Then make sure that you reference the font by its proper name -- you'll see the possible names in the Fonts folder.  It might be something like "Lato Regular" that you want.

Check out SAS Innovate on-demand content! Watch the main stage sessions, keynotes, and over 20 technical breakout sessions!
HGimenez
Obsidian | Level 7

Thanks a lot. The proper name seems to be "Lato Regular" (per c:\windows\fonts\lato) but still doesn't work

 

I changed the code to:

 

proc fontreg mode=add;
fontpath 'Z:\lato';
run;

ODS PDF FILE='c:\temp\1.pdf';

PROC REPORT
		STYLE(COLUMN)={font_face='Lato Regular'}
		DATA=SASHELP.CLASS
		;
	RUN;

ODS PDF CLOSE;

Any other ideas??

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 3 replies
  • 1260 views
  • 3 likes
  • 2 in conversation