BookmarkSubscribeRSS Feed
aravind
Fluorite | Level 6
Hi SAS People.

Well, I am trying to create reports using sas Enterprise Guide 4.2 in PDF.
By the way i am not using any GUI features. I am writing the code from scratch as how we do it in Base SAS.
If I use Courier or Courier New, then i will have no issues of distortion of report.
But, now the problem is our client requested that the font needs to be in Times New Roman and size should be 10pt.

Is it possible to create reports in PDF with TimesNewRoman 10pt with exact alignment?

So, how do we use times new roman, since it is a variable font in PDF destination.
If we use Proc report, the distortion is little but When i use Data _null_ for the reporting, then it looks impossible to align and I am totally lost how to set the linesize for the Times New Roman 10pt .

I dont understand why there is a difference of alignment between Data _null_ and Proc Report?
Is it possible to make Times New Roman 10pt in PDF destination to a monospace font.
if not how can I create a report in pdf using Times New Roman 10pt without distortion.
For example, I used data _null_ to just print 4 columns and i set the LS=125 to create a report in PDF and when I look at the report it looks weird and i see very bad alighnment.
I changed the LS many times and couldn't get proper alignment in the report.
The Put @ doesn't work proper at all.
So, I am totally lost and need help and if anybody has any kind of idea, I would really appreciate their help.


Thanks & Regards
Aravind.
17 REPLIES 17
ArtC
Rhodochrosite | Level 12
Courier New and Courier are non-proportional fonts - every character has equal width. Times New roman is a proportional font - W is wider than i.

So in REPORT what is not being aligned???? Perhaps you are using the LISTING destination and converting to PDF?? Otherwise REPORT aligns at the column level, while DATA _NULL_ aligns at the page level.
aravind
Fluorite | Level 6
Well, I am not using the listing destination.
I am using the ODS PDF destination.

I am using the Data _Null_ . If u look at the following sample code. The headers getting wrapped closely and the variable values are not aligning properly.
I changed line size at (file print ls=) many times but still no proper alignment.

proc template;
define style Styles.Custom;
parent=styles.printer;
style batch from batch /
font_face="Times New Roman"
font_size=10pt ;
STYLE Header /
font_face = "Times New Roman"
font_size = 10pt
font_weight = medium;
end;
run;
OPTIONS NODATE NONUMBER NOBYLINE ORIENTATION=LANDSCAPE;
ODS ESCAPECHAR = "~";
ODS PDF FILE = "SAMS.pdf" COMPRESS=0 NOTOC STYLE=Custom;
data _null_;
set test end=eof;
file print header=newpage ls=150;
line = repeat("_",123);
if _N_ = 1 then do;
put @1 "NAME" +10 "AGE" +5 "LOCATION";
put @1 line/;
put @1 name $8. +6 age 2. +6 location $13.;
end;
else do;
put @1 name $8. +6 age 2. +6 location $13.;
end;

if eof then do;
put///;
put @48 "*** END OF REPORT ***";
end;

return;
newpage:
put @1 "REPORT:xxxxx-xxx" +30 "xxxx" +15 "PROCESS DATE:12/02/2010"/
@1 "xxx:xx" +1"xxxxxx" +1 "PROCESS TIME:11:39:15"/
@101 "PAGE: 1"/
@48 "SAMPLE TESTING REPORT"///;
return;

run;
ODS PDF CLOSE;
ArtC
Rhodochrosite | Level 12
As Cynthia suggested, take a look at PROC REPORT. Ithink that you will be much happier with the result.
Cynthia_sas
SAS Super FREQ
Well, I'm not entirely sure what you're trying to achieve, but I'd be tempted to try something like what's produced by the program below.

cynthia
[pre]
data test;
set sashelp.shoes;
if _n_ lt 125;
name=product;
age=stores;
location = region;
run;


options orientation=landscape nodate nonumber center;
ods pdf file='c:\temp\report_alt.pdf' style=journal notoc
uniform;
ODS ESCAPECHAR = "~";
** ~_ puts a non-breaking space in TITLE1;
title1 j=l "REPORT:xxxxx-xxx ~_~_~_~_~_~_~_~_~_ xxxx" j=r "PROCESS DATE:12/02/2010";
title2 j=l "xxx:xx xxxxxx PROCESS TIME:11:39:15" j=r 'Page: ~{thispage}';
title3 j=c "SAMPLE TESTING REPORT";
title4 ' ';
title5 ' ';

proc report data=test nowd
style(header)={font_face = "Times New Roman"
font_size = 10pt
font_weight = medium
font_style=roman};
column name age location stores inventory sales returns;
run;

ods pdf close;
[/pre]
Cynthia_sas
SAS Super FREQ
Oops, forgot about data cells. Cynthia
[pre]
proc report data=test nowd
style(header)={font_face = "Times New Roman"
font_size = 10pt
font_weight = medium
font_style=roman}
style(column)={font_face = "Times New Roman"
font_size = 10pt
font_weight = medium
font_style=roman};
column name age location stores inventory sales returns;
run;


[/pre]
aravind
Fluorite | Level 6
Thanks for the Help Cynthia.
I guess I have to say GoodBye to Data _null_ based on your explanation inorder to get a decent report in PDF Destination!

Is it possible to do any kind of report in Proc Report compared to Data _null_?

And is there a way to define one style template with font_face=Times New Roman and include into the proc report so that it applies to the whole report the same font? Instead of mentioning more than one place in proc report?>
Cynthia_sas
SAS Super FREQ
Hi:
It is possible to do most TABULAR reports in PROC REPORT instead of DATA _NULL_. Totally "free-format" reports are not possible in PROC REPORT -- to do those (such as an invoice or a brochure or an annual report), you must move into the world of ODS LAYOUT. But, your report was mostly TABULAR, with fancy titles and custom page numbering. Very do-able in PROC REPORT.

Yes, it is possible to define a style template with the font_face set to Times New Roman for every report element. Then you could use the style template with EVERY procedure, not just proc report. What version of SAS are you running? SAS 9.1.3 or SAS 9.2? The syntax for the style template would be different depending on your version -- 9.2 syntax with the CLASS statement is shown below -- I did not bother to adjust the font sizes -- but you can easily do that if you want -- I like the heading slightly larger than the data cells. This paper shows the 9.2 syntax for style templates:
http://support.sas.com/resources/papers/proceedings10/033-2010.pdf

cynthia
[pre]
ods path work.tmp(update) sashelp.tmplmst(read);
proc template;
define style styles.myprt;
parent=styles.journal;
class fonts /
'TitleFont2' = ("Times New Roman, Times Roman",12pt,bold italic)
'TitleFont' = ("Times New Roman, Times Roman",13pt,bold italic)
'StrongFont' = ("Times New Roman, Times Roman",10pt,bold)
'EmphasisFont' = ("Times New Roman, Times Roman",10pt,italic)
'FixedEmphasisFont' = (", Courier",9pt,italic)
'FixedStrongFont' = (", Courier",9pt,bold)
'FixedHeadingFont' = (", Courier",9pt,bold)
'BatchFixedFont' = ("SAS Monospace, , Courier",6.7pt)
'FixedFont' = (", Courier",9pt)
'headingEmphasisFont' = ("Times New Roman, Times Roman",11pt,bold italic)
'headingFont' = ("Times New Roman, Times Roman",11pt,bold)
'docFont' = ("Times New Roman, Times Roman",10pt);
end;
run;

options orientation=landscape nodate nonumber center;
ods pdf file='c:\temp\report_alt_font.pdf' style=styles.myprt notoc
uniform;
ODS ESCAPECHAR = "~";

** ~_ puts a non-breaking space in TITLE1;
title1 j=l "REPORT:xxxxx-xxx ~_~_~_~_~_~_~_~_~_ xxxx" j=r "PROCESS DATE:12/02/2010";
title2 j=l "xxx:xx xxxxxx PROCESS TIME:11:39:15" j=r 'Page: ~{thispage}';
title3 j=c "SAMPLE TESTING REPORT";
title4 ' ';
title5 ' ';

proc report data=test nowd;
column name age location stores inventory sales returns;
run;

ods pdf close;
[/pre]
aravind
Fluorite | Level 6
Hi Cynthia,

I've gone through the style template that you have created to apply the Times New Roman font to every component in the report.

But why do I see different fonts in the style template like Monospace, Courier, Italic?
I am kindda new to Proc Template and If u could explain a little, I would really appreciate.

And for the PDF destination, what are the default styles that we can use in the reports either directly or by modifing them?(I thought we can use only styles.printer)
And can u explatin the different fonts u created in the style template like,
what exactly their definition, for example
Whats the difference betweeen TitleFont2 and TitleFont,

what is StrongFont, FixedEmphasisFont....?

By the I am using SAS EG 4.2 and SAS 9.2.

Thanks & Regards
Aravind
Cynthia_sas
SAS Super FREQ
Hi:
Think of the style template as being the universe of all the -possible- style elements that -any- SAS procedure could ask for.

So, for example, do you use PROC CALENDAR or PROC COMPARE??? They might call for or need a "Monospace" font to have the results appear correctly, and so there's a style attribute in the style template for a MONOSPACE font. For example, the style attribute "BatchFixedFont" is used by the "BATCH" style element -- and if you changed the "BatchFixedFont" to be something like Times New Roman, then when you ran PROC CALENDAR, the output wouldn't look very good at all.

If it makes you happy (and if you're not using PROC CALENDAR or PROC COMPARE -- those are the only 2 I can think of) then go ahead and change all the occurences of Courier New or Monospace to Times New Roman. I just don't normally mess with the Batch-y or Monospace fonts because if I do happen to use my new template with PROC CALENDAR or PROC COMPARE, I want the monospace look and feel of that output to be unchanged.

To explain EVERYTHING about style templates and fonts and colors took 2 or 3 chapters in my book with Lauren Haworth and Michele Burlew (Output Delivery System: The Basics and Beyond) -- and even then, I don't think we explained -EVERYTHING-, but we came close. That's certainly more information than I could put into a forum post. The ODS documentation on Style templates takes some reading, but it is quite thorough and there are many user-group papers, which are aimed at beginners. I happen to like these:
Tiptoe Through the Templates http://support.sas.com/resources/papers/proceedings09/227-2009.pdf
SAS Style Templates: Always in Fashion http://support.sas.com/resources/papers/proceedings10/033-2010.pdf

So I will let you explore the papers and documentation on your own.

As for how TitleFont versus TitleFont2 is used -- if you look down inside STYLES.DEFAULT, you will see that TitleFont2 is used for the high level TitlesandFooters style element, while TitleFont is used by the specific SystemTitle style element:
[pre]
class TitlesAndFooters /
font = Fonts('TitleFont2')
backgroundcolor = colors('systitlebg')
color = colors('systitlefg');

class SystemTitle /
font = Fonts('TitleFont');

class ProcTitle /
backgroundcolor = colors('proctitlebg')
color = colors('proctitlefg');
[/pre]

So any style element that inherited style attributes from TitlesAndFooters element would get TitleFont2 UNLESS, as is the case with SystemTitle -- the font is overridden to use the TitleFont attribute. The ProcTitle style element, on the other hand, also inherits from TitlesandFooters style element, but it only overrides the colors and so it uses TitleFont2.

For the PDF destination, the default style template is STYLES.PRINTER -- but that template also inherits from its parent template, STYLES.DEFAULT. You could use just about any template for the Printer-family of destinations. I generally use "white background" templates -- such as STYLES.PRINTER (or any template with "printer" in the name) -- The big difference between STYLES.PRINTER and STYLES.DEFAULT is that STYLES.DEFAULT is designed for use with "relative" font sizes -- such as you use for web browsers and HTML output; whereas STYLES.PRINTER defines all the styles in point sizes.

The nice thing about SAS 9.2 and style templates is that you do not have to stress over the inheritance hierarchy -- you just have to understand about how the elements and attributes work so you can override what you want. For example, if you wanted to override the style for ProcTitle and SystemTitle directly, without worrying about inheritance, you can just do this:
[pre]
class SystemTitle /
font = ("Times New Roman, Times, serif",14pt,bold italic)
backgroundcolor=white
color=green;

class ProcTitle /
font=("Times New Roman, Times, serif",12pt,bold italic)
backgroundcolor = white
color = purple;
[/pre]

I hope this information gets you pointed in the right direction with style templates.

cynthia
aravind
Fluorite | Level 6
Hi Cynthia,

Thats a lot of information and I really really appreciate your time and explanation.

Few things.

Here at my work, we dont use the PROC COMPARE or PROC CALENDER with the style template which means I can change non times new roman fonts to Times New Roman fonts based on your explanation.

Here at my company, the client requested all the reports should be in PDF and the font should be Times New Roman with a size of 10pt.

So, I have modifed the style template that you have created earlier and pasting it here.
If you could let me know, if anything is wrong in it. If everything is right, then I will be using this style template from nowonwards for my reports.

ods path work.tmp(update) sashelp.tmplmst(read);
proc template;
define style styles.mystyle;
parent=styles.printer;

class fonts /
'TitleFont2' = ("Times New Roman",10pt,medium roman)
'TitleFont' = ("Times New Roman",10pt,medium roman)
'StrongFont' = ("Times New Roman",10pt,medium)
'EmphasisFont' = ("Times New Roman",10pt,roman)
'FixedEmphasisFont' = ("Times New Roman",10pt,roman)
'FixedStrongFont' = ("Times New Roman",10pt,medium)
'FixedHeadingFont' = ("Times New Roman",10pt,medium)
'BatchFixedFont' = ("Times New Roman",10pt)
'FixedFont' = ("Times New Roman",10pt)
'headingEmphasisFont' = ("Times New Roman",10pt,medium roman)
'headingFont' = ("Times New Roman",10pt,medium)
'docFont' = ("Times New Roman",10pt);

class TitlesAndFooters /
font = Fonts('TitleFont2');

class SystemTitle /
font = Fonts('TitleFont');

class Header/
background=_undef_;

class UserText from SystemTitle/ just=c;

class table /
frame=void
borderspacing=0
rules = none;
end;
run;

Assuming that, I have covered all the style elements to implement Times New Roman with a size of 10pt for my reports in PDF.

Your feedback will be greatly appreciated.

Thanks & Regards
Aravind
Cynthia_sas
SAS Super FREQ
Hi:
The syntax looks OK to me. The question is -- does it produce the desired results when you run using your procedure(s) of choice. If so, then good job!

I could only remember PROC COMPARE and PROC CALENDAR as using the BATCH style element, for example. I can't tell you if "everything" is "right" -- you're the only one who can answer that question. When you use the template with ALL the procedures used for this client's reports, are the fonts in 10 pt Times New Roman??? Is everything as YOU and YOUR client expect??

I only have 1 comment....in my opinion, it is a good habit to provide "alternate" fonts in the font list. That is why I had something like:
[pre]
("Times New Roman, Times, serif",10pt,bold italic)
[/pre]

in my example -- this says that if the viewing system does not have a font named EXACTLY "Times New Roman", then to look, as a second choice for the font named "Times" and if neither of those fonts was available on the viewing system to use a "serif-based" font.

I consider the use of alternate fonts to be a "best practice" and it avoids the inevitable issue of when person 1 looks at output on their system, they have a font EXACTLY named "Times New Roman" and so things appear as you expect, but person 2 does not have EXACTLY "Times New Roman" (for whatever reason) and they get the default font for the viewing system and application -- which may not be the best scenario.

cynthia
Cynthia_sas
SAS Super FREQ
Hi:
Using PUT statements with DATA _NULL_ with ODS, such as PUT @15 or PUT @32 will rarely result in "lined up" output. For example, consider the following 2 examples:
Proportional Spaced Font
iiiiiiiiiiiiiiiiiiii
wwwwwwwwwwwwwwwwwwww

Fixed Pitch Font
[pre]
iiiiiiiiiiiiiiiiiiii
wwwwwwwwwwwwwwwwwwww
[/pre]

Both examples contain 20 letter 'i' and 20 letter 'w'. As you can see in a proportional spaced font (such as Times New Roman), the letter 'i' takes up less horizontal space than the letter 'w'; whereas, in the fixed pitch font, both letters take up the same amount of space.

Depending on the type of report you need to create, you may find that DATA _NULL_ techniques no longer work for you. Many of my students who used to do DATA _NULL_ with PUT statements switched over to PROC REPORT with ODS.

Without a better idea of the code you're using or the report you need to produce, it is very hard to give more advice. You may want to work with Tech Support, as they can look at your program and your data and provide you some feedback on possible alternatives.

cynthia
Michelle
Obsidian | Level 7

I am glad I found this thread, it is nice to know I  am not the only one with this problem... I have several programs I inherited that use data _null_ to print very customized "free form" reports, and have been trying to use with ODS PDF (instead of the old method of jsut  printing the SAS output screen to a PDF file). I get perfect alignment with monospace fonts, but if I switch to more readable non-monospace fonts, ODF PDF file output is not aligned correctly, even though the data step is using put @_ to specify where each variable goes on each line.  Sounds like ODS Layout is where I am headed if I want readable printed reports...

Michelle
Obsidian | Level 7

Partially fixed some of the problem by setting options nocenter. Not sure why this only needs to be done with proportional font and not with monospace font.

But the option nocenter doesnt get rid of the problem of putting variables at 'fixed' points on the page.

http://support.sas.com/kb/24/227.html

http://support.sas.com/kb/5/486.html

http://support.sas.com/kb/9/981.html

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 17 replies
  • 5564 views
  • 2 likes
  • 4 in conversation