The SAS Output Delivery System and reporting techniques

TEMPLATE/STYLE change font family and size

Accepted Solution Solved
Reply
Frequent Contributor
Posts: 83
Accepted Solution

TEMPLATE/STYLE change font family and size

How does one change the font family and size in output, particularly in ODS destinations like PDF.

 

Creating a new style definition using the TEMPLATE procedure with inheritance would seem to be appropriate, but even when I use the STYLE= option in the ODS PDF statement, it did not seem to help.

 

proc template ;

  define style
            styles.fda
            ;

    parent = styles.pearl ;

     class fonts
        / "TitleFont"           = ( Arial   , 10pt )
          "TitleFont2"          = ( Arial   , 10pt )
          "StrongFont"          = ( Arial   , 10pt , bold )
          "EmphasisFont"        = ( Arial   ,  9pt , italic )
          "FixedEmphasisFont"   = ( Courier ,  9pt )
          "FixedStrongFont"     = ( Courier ,  9pt , bold )
          "FixedHeadingFont"    = ( Courier ,  9pt , bold )
          "BatchFixedFont"      = ( Courier ,  9pt )
          "FixedFont"           = ( Courier ,  9pt )
          "headingEmphasisFont" = ( Arial   ,  9pt , bold italic )
          "headingFont"         = ( Arial   ,  9pt , bold )
          "docFont"             = ( Arial   ,  9pt )
          ;

      style data from data
         / font = fonts( "docFont" )
           ;

  end ;

run ;

 I was able to change the individual attributes for the various location in the PRINT procedure.  What can one do if one wants to direct the output of a procedure like GLM or MIXED to PDF, but have the font be a certain family and size.  Currently, it appears to be Albany.

 

Thank you,

 

Kevin

 

 


Accepted Solutions
Solution
‎09-11-2016 10:24 AM
SAS Super FREQ
Posts: 8,820

Re: TEMPLATE/STYLE change font family and size

Hi:

  REPLACE was deprecated in 9.2 and it was my understanding that if you use REPLACE now, in 9.2, 9.3 or 9.4 that it will behave the same way as STYLE or CLASS statements in PROC TEMPLATE. However, I was always advised to use the "official" name of the Arial font, which in PDF-land is "Arial Unicode MS" and also advised to always use the "official" name of the Courier font, which is "Courier New". As you can see from the screen shot below (I did change the original template so the changes were obvious), when I use those font names, the correct fonts are embedded and appear to be used.

 

  To make specific changes to PROC PRINT data cells or header cells or areas like the summary line, the OBSHEADER and the OBS numbers, you need to use STYLE(area)= overrides in the PROC PRINT syntax, as shown in the second example.

 

cynthia

 

useArialUnicode.png

View solution in original post


All Replies
Super User
Posts: 19,167

Re: TEMPLATE/STYLE change font family and size

Try Replace Fonts? 

 

This is is an example of one I use. 

 

https://gist.github.com/statgeek/9603140

 

 

 

 

Solution
‎09-11-2016 10:24 AM
SAS Super FREQ
Posts: 8,820

Re: TEMPLATE/STYLE change font family and size

Hi:

  REPLACE was deprecated in 9.2 and it was my understanding that if you use REPLACE now, in 9.2, 9.3 or 9.4 that it will behave the same way as STYLE or CLASS statements in PROC TEMPLATE. However, I was always advised to use the "official" name of the Arial font, which in PDF-land is "Arial Unicode MS" and also advised to always use the "official" name of the Courier font, which is "Courier New". As you can see from the screen shot below (I did change the original template so the changes were obvious), when I use those font names, the correct fonts are embedded and appear to be used.

 

  To make specific changes to PROC PRINT data cells or header cells or areas like the summary line, the OBSHEADER and the OBS numbers, you need to use STYLE(area)= overrides in the PROC PRINT syntax, as shown in the second example.

 

cynthia

 

useArialUnicode.png

Frequent Contributor
Posts: 83

Re: TEMPLATE/STYLE change font family and size

Thanks to both Cynthia and Reeza for offering solutions.

 

Pearl inherits from Printer, which appears to go to "base" elements.  In Printer, ContentTitle  specifies font = fonts('TitleFont') and in Pearl Data specifies font = fonts('DocFont').  In the case of the latter, I do not have to repeat the CLASS (or STYLE) statement in my custom template, but only need to change the font family and size in Font.

 

Cynthia included SystemTitle, but my experimentation suggested previously that it was already covered by TitleFont.  I would imagine that each location is covered by reference or inheritance, but I would still be interested in a listing of each for each style template/procedure.

 

I appreciate the advice and corrections.

 

Thank you,

 

Kevin

 

SAS Super FREQ
Posts: 8,820

Re: TEMPLATE/STYLE change font family and size

Hi:
You can get a listing of each style template by using PROC TEMPLATE syntax. Please refer to this paper for an example of PROC TEMPLATE "utility" syntax:
https://support.sas.com/resources/papers/proceedings09/227-2009.pdf

and to this paper for an explanation of the way inheritance works in SAS 9.2 and higher:
https://support.sas.com/resources/papers/proceedings10/033-2010.pdf

If you look at the template "master" BASE.TEMPLATE.STYLE, you will see that SystemTitle inherits from TitlesAndFooters style element:
style SystemTitle from TitlesAndFooters
"Controls system title text.";

To see the inheritance between style elements--
Pearl inherits from Printer which inherits from Default which inherits from Base.Template.Style. So when you are tracing inheritance (which you needed to do more in 9.1.3 than in 9.2 and higher), you can't just go to the previous template, sometimes, you have to go all the way back to the father, grandfather and greatgrandfather template.

But, as I explained in my paper and as Kevin Smith explained here -- style inheritance was enormously simplified starting with SAS 9.2: http://www2.sas.com/proceedings/sugi31/053-31.pdf

cynthia
☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 4 replies
  • 846 views
  • 3 likes
  • 3 in conversation