BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
polarjud
Obsidian | Level 7

The code below produces a report in Arial Narrow, as desired, in the HTML results window, but in Helvetica in the RTF file.  So perplexing.  Why are my instructions being overridden by some random default?

 

data SimpleTest;
input treatment trainingMonths_LO;
cards;
1 13
0 12
1 10
0 3
;
run;
 
ods rtf file='S:\projects\HPOG_2.0_Eval\Analysis\04 Outputs\LTIR\JunkTest.rtf';
proc report data=SimpleTest
style(report)=[fontfamily="'Arial Narrow'"]
style(header)=[fontfamily="'Arial Narrow'"]
style(column)=[fontfamily="'Arial Narrow'"];
column treatment (Mean Std),trainingMonths_LO;
define treatment/group;
define trainingMonths_LO/format=6.2;
    title 'Months of training';
run;
ods rtf close;

 

1 ACCEPTED SOLUTION

Accepted Solutions
Cynthia_sas
SAS Super FREQ

Hi:

Fonts have to be registered in SAS before you can use them. You can see if Arial Narrow is registered to SAS by running the following PROC REGISTRY step:

proc registry startat="\CORE\PRINTING\FREETYPE\FONTS" list;
run;

Is Arial Narrow listed in the log?

I had the same issue you experienced, with Arial Narrow not being used. However,  I needed to run PROC FONTREG to add Arial Narrow to the SAS Registry:

proc fontreg mode=all msglevel=verbose;
fontfile "c:\windows\fonts\arialn.ttf";
run;

  The name of Arial Narrow is arialn.ttf (True Type Font).

And after I used PROC FONTREG to update the SAS Registry then this code worked as expected.

Cynthia_sas_1-1719936587038.png

 

 

Cynthia_sas_0-1719936522908.png

  I ran the code in 9.4M7, but I would expect that 9.4M8 would work the same way.

If using PROC FONTREG doesn't work you may need to get help from your system admin or SAS Tech Support. I did my test on Windows, however keep in mind that Arial may not be a font that's available on a Linux/Unix/mainframe system.

Cynthia

View solution in original post

3 REPLIES 3
Cynthia_sas
SAS Super FREQ

Hi:

Fonts have to be registered in SAS before you can use them. You can see if Arial Narrow is registered to SAS by running the following PROC REGISTRY step:

proc registry startat="\CORE\PRINTING\FREETYPE\FONTS" list;
run;

Is Arial Narrow listed in the log?

I had the same issue you experienced, with Arial Narrow not being used. However,  I needed to run PROC FONTREG to add Arial Narrow to the SAS Registry:

proc fontreg mode=all msglevel=verbose;
fontfile "c:\windows\fonts\arialn.ttf";
run;

  The name of Arial Narrow is arialn.ttf (True Type Font).

And after I used PROC FONTREG to update the SAS Registry then this code worked as expected.

Cynthia_sas_1-1719936587038.png

 

 

Cynthia_sas_0-1719936522908.png

  I ran the code in 9.4M7, but I would expect that 9.4M8 would work the same way.

If using PROC FONTREG doesn't work you may need to get help from your system admin or SAS Tech Support. I did my test on Windows, however keep in mind that Arial may not be a font that's available on a Linux/Unix/mainframe system.

Cynthia

polarjud
Obsidian | Level 7

Worked like a charm.  Thanks, so much, Cynthia.

louisehadden
Quartz | Level 8

Hi there. Many SAS installs may not have particular fonts available in the SAS registry. The way to make this happen is to use PROC FONTREG with the FONTPATH statement, after downloading the Arial font family into the FONTPATH directory. Note that your install may not allow you to mess with the registry and/or system fonts, so use your own folder to add the desired font for the duration of your session - the fontpath allows you to grab a font from anywhere. Be aware that this is temporary! You will want to make sure the fontembedding system option is set. 

 

options fontembedding ps=55 ls=175 errorabend;

libname dd '.';
filename odsout '.';
run;

title1 "HPOG rtf test";
run;

proc fontreg msglevel=verbose;
fontpath 'S:\projects\QRPVBP\HH_QRP\_Source_Data\iQIES\OASIS\2023Q1_2023Q4\sandbox';
run;

 

NOTE: The font "Arial Narrow" (Style: Regular, Weight: Normal) has been added to the SAS Registry at [CORE\PRINTING\FREETYPE\FONTS\<ttf> Arial Narrow]. Because it is a TRUETYPE font, it can be referenced as "Arial Narrow" or "<ttf> Arial Narrow" in SAS. The font resides in file
"S:\projects\QRPVBP\HH_QRP\_Source_Data\iQIES\OASIS\2023Q1_2023Q4\sandbox\ARIALN.TTF".

NOTE: The font "Arial Narrow" (Style: Regular, Weight: Bold) has been added to the SAS Registry at [CORE\PRINTING\FREETYPE\FONTS\<ttf> Arial Narrow]. Because it is a TRUETYPE font, it can be referenced as "Arial Narrow" or "<ttf> Arial Narrow" in SAS. The font resides in file
"S:\projects\QRPVBP\HH_QRP\_Source_Data\iQIES\OASIS\2023Q1_2023Q4\sandbox\ARIALNB.TTF".

NOTE: The font "Arial Narrow" (Style: Italic, Weight: Bold) has been added to the SAS Registry at [CORE\PRINTING\FREETYPE\FONTS\<ttf> Arial Narrow]. Because it is a TRUETYPE font, it can be referenced as "Arial Narrow" or "<ttf> Arial Narrow" in SAS. The font resides in file
"S:\projects\QRPVBP\HH_QRP\_Source_Data\iQIES\OASIS\2023Q1_2023Q4\sandbox\ARIALNBI.TTF".

NOTE: The font "Arial Narrow" (Style: Italic, Weight: Normal) has been added to the SAS Registry at [CORE\PRINTING\FREETYPE\FONTS\<ttf> Arial Narrow]. Because it is a TRUETYPE font, it can be referenced as "Arial Narrow" or "<ttf> Arial Narrow" in SAS. The font resides in file
"S:\projects\QRPVBP\HH_QRP\_Source_Data\iQIES\OASIS\2023Q1_2023Q4\sandbox\ARIALNI.TTF".

 

Then add the font group.

proc fontreg;
fontfile '<ttf> Arial Narrow';
run;


data SimpleTest;
input treatment trainingMonths_LO;
cards;
1 13
0 12
1 10
0 3
;
run;

ods rtf file='.\vanillaTest.rtf'; /* will use the default style template for RTF */
proc report data=SimpleTest
style(report)=[fontfamily="'Arial Narrow'"]
style(header)=[fontfamily="'Arial Narrow'"]
style(column)=[fontfamily="'Arial Narrow'"];
column treatment (Mean Std),trainingMonths_LO;
define treatment/group;
define trainingMonths_LO/format=6.2;
title2 'Months of training - Vanilla';
run;
ods rtf close;

 

ods rtf file='.\defineTest.rtf'; /* adds font specs to the define statements */
proc report data=SimpleTest
style(report)=[fontfamily="'Arial Narrow'"]
style(header)=[fontfamily="'Arial Narrow'"]
style(column)=[fontfamily="'Arial Narrow'"];
column treatment (Mean Std),trainingMonths_LO;
define treatment / group style(COLUMN)={just=c font_face="Arial Narrow" foreground=navy
font_size=9pt cellwidth=180 }
style(HEADER)={just=c font_face="Arial Narrow" font_weight=bold
font_size=9pt };
define trainingMonths_LO / style(COLUMN)={just=c font_face="Arial Narrow" foreground=navy
font_size=9pt cellwidth=180 format=6.2}
style(HEADER)={just=c font_face="Arial Narrow" font_weight=bold
font_size=9pt };
title2 'Months of training - add style override';
run;
ods rtf close;

 

Both tests that use the style statements / overrides succeed in using the Arial Narrow font. PROC FONTREG is pretty cool - especially if you want to write in Klingon font. 

https://www.lexjansen.com/nesug/nesug07/po/po12.pdf

 

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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
  • 251 views
  • 10 likes
  • 3 in conversation