BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Chiron77omus
Fluorite | Level 6

I am trying to specify use of a uniform font (Courier New) for the body of a data step report that is written to the RTF output destination (final report and SAS source and dummy data are attached).  I have been trying to find style options that will control this but can't seem to get it to work.  My results always use SAS monospace which is fine for me but not target clients who do not have SAS installed.  I understand that use of FORMCHAR options should yield a portable document that would not have this issue but cannot check this until the client returns in a week since all PCs I have access to now have SAS installed.  

 

Put simply, can the font for the data step report body be controlled for this output destination, and if so, how?  It seems like it should be easy but all of the style and ODS documentation just doesn't register with me (when I started with SAS we were printing on green bar paper, so none of this was relevant when I started with data step reports :-)).

 

Thanks. - Curt

1 ACCEPTED SOLUTION

Accepted Solutions
ballardw
Super User

Don't make us guess which file to look at for which purpose.

 

From this note http://support.sas.com/kb/39/461.html you might try this STYLE

 

proc template;
   define style test;
      style fonts     / "XFont" = ("Courier New",9pt);
      style Container / font = Fonts('XFont');
   end;
run;
quit;

Your ODS RTF statement would add: Style=test (or what ever name you may give the style). Output destinations like RTF and PDF have their own default styles and if you do not provide an alternative it does not matter what fonts are used in table descriptions templates. The ODS destination will reformat to its style.

 

You may also want to investigate either Proc ODSTEXT, which lets you mix repeated display elements based on variables in a data set and boilerplate text. Or the data step Report Writing Interface which gives you a log of control for column/row appearances. Either of these might get away from worrying about using a fixed font like Courier to align text.

 

Does that Body= throw any messages in the log? Body is typically for HTML and RTF would more frequently use File= .

 

You may have issues with leading spaces disappearing. Multiple macros without definition make your code impossible to actually test.

 

Please post code into text boxes opened using the </> or a code box opened with the "running man" icon.

If you think the code is too long to include then consider if it is needed.

 

View solution in original post

3 REPLIES 3
ballardw
Super User

Don't make us guess which file to look at for which purpose.

 

From this note http://support.sas.com/kb/39/461.html you might try this STYLE

 

proc template;
   define style test;
      style fonts     / "XFont" = ("Courier New",9pt);
      style Container / font = Fonts('XFont');
   end;
run;
quit;

Your ODS RTF statement would add: Style=test (or what ever name you may give the style). Output destinations like RTF and PDF have their own default styles and if you do not provide an alternative it does not matter what fonts are used in table descriptions templates. The ODS destination will reformat to its style.

 

You may also want to investigate either Proc ODSTEXT, which lets you mix repeated display elements based on variables in a data set and boilerplate text. Or the data step Report Writing Interface which gives you a log of control for column/row appearances. Either of these might get away from worrying about using a fixed font like Courier to align text.

 

Does that Body= throw any messages in the log? Body is typically for HTML and RTF would more frequently use File= .

 

You may have issues with leading spaces disappearing. Multiple macros without definition make your code impossible to actually test.

 

Please post code into text boxes opened using the </> or a code box opened with the "running man" icon.

If you think the code is too long to include then consider if it is needed.

 

Chiron77omus
Fluorite | Level 6

My apologies for elements of my original post being less than clear and concise.  I rarely post questions to SAS Community forums so am not well versed in etiquette.  The original problem actually is based on code I wrote over 20 years ago and uses various macros and included code (such as the formats I posted) and cycles through hundreds of reports per run.  I thought I had reduced the problem to a single report without any need for the macro library but forgot there are little macros called that simply generate a line of dashes or double dashes in the data step report. 

 

The suggestion by ballardw with the define style test statement worked the first time I tried it (*Thank You*) - I did also specify the style=test in the ODS RTF file= statement as part of the solution. 

 

I do not understand why it works - I don't know where XFont comes from, nor what the style Container statement does exactly - seems like it indirectly associates the Courier New font to the RTF output (kind of like a libref in a libname statement associates a directory with a SAS data set) ???  

 

I had tried many variations similar to the other post (prior to submitting my question) but none of the variations I tried ever impacted the data step report body - I could control the titles but never the body.  Clearly there are many things about how the Proc Template works with ODS that I will never understand ... Curt

Reeza
Super User

Here's the style template I've used historically for RTF files. 

 

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

 

/*This program is a template for a tight table style for Word Documents,
RTF.  
Originally written by Ryan Woods, BC Cancer Agency*/

proc template;
 define style styles.newrtf;
 parent=styles.rtf;
 style header / background = white font=(Times, 11pt, Bold);
 replace fonts /
   'TitleFont2' = ("Times",12pt,Bold Italic)
   'TitleFont' = ("Times",12pt,Bold)
   'StrongFont' = ("Times",11pt,Bold)
   'EmphasisFont' = ("Times",11pt,Italic)
   'FixedEmphasisFont' = ("Courier New, Courier",10pt,Italic)
   'FixedStrongFont' = ("Courier New, Courier",10pt,Bold)
   'FixedHeadingFont' = ("Courier New, Courier",10pt,Bold)
   'BatchFixedFont' = ("SAS Monospace, Courier New, Courier",8pt)
   'FixedFont' = ("Courier New, Courier",10pt)
   'headingEmphasisFont' = ("Times",12pt,Bold Italic)
   'headingFont' = ("Times",11pt,Bold)
   'docFont' = ("Times",9pt);
replace Table from Output /
rules = all 
cellspacing = 0.5pt
cellpadding = 2.0pt;
end;
run;

ods listing close;
ods rtf file="C:\temp\sample_rtf.rtf" style=styles.newrtf;

proc report nowd data= sashelp.class spanrows;
column sex name ('Measurements' age height weight);
define sex /'Sex' order;
define name / 'Name'order;
define age/ 'Age' order;
define height/ 'Height' format=8.1;
define weight/ 'Weight' format=8.1;
run;

ods rtf close;
ods listing;

@Chiron77omus wrote:

I am trying to specify use of a uniform font (Courier New) for the body of a data step report that is written to the RTF output destination (final report and SAS source and dummy data are attached).  I have been trying to find style options that will control this but can't seem to get it to work.  My results always use SAS monospace which is fine for me but not target clients who do not have SAS installed.  I understand that use of FORMCHAR options should yield a portable document that would not have this issue but cannot check this until the client returns in a week since all PCs I have access to now have SAS installed.  

 

Put simply, can the font for the data step report body be controlled for this output destination, and if so, how?  It seems like it should be easy but all of the style and ODS documentation just doesn't register with me (when I started with SAS we were printing on green bar paper, so none of this was relevant when I started with data step reports :-)).

 

Thanks. - Curt


 

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
  • 1595 views
  • 1 like
  • 3 in conversation