BookmarkSubscribeRSS Feed
NeilH
Obsidian | Level 7

I'm trying to write to a pdf file using proc odstext and getting additional spaces before some of the words I'm applying the inline style to. This seems to occur regardless of the actual style attribute (bold, italic, underline, ...). I noticed an almost identical post (https://communities.sas.com/t5/ODS-and-Base-Reporting/ODS-TEXT-produces-uneven-spacing-in-PDF-output...) from some years back that wasn't resolved. And another post that mentions some Microsoft specific fonts causing issues.

 

The issue doesn't occur without the inline style command or with html output to the browser rather than creating a pdf. It also doesn't matter whether the text comes from a macro variable or not.

 

I'm including code and example output. You can see the additional spaces before some of the bolded numbers in the text. I appreciate anyone's thoughts on this matter. Thanks.

 

%let school = "Acme U";
goptions reset=all device=SASPRTC;
ods _ALL_ close;
%let folder = M:\Engagement Surveys - 2024\Scratch\;
%let filename = %sysfunc(dequote(&school));
%let extension = .pdf;
options nodate;
ods pdf file="&folder&filename&extension" startpage=no;

data _null_;
set qc_temp1;
call symputx('faculty', f_count);
call symputx('students', s_count);
run;

ods proclabel = "Introduction";
proc odstext pagebreak = YES;
ods escapechar='^';

p
"Nationally, ^{style[font_weight=Bold]134} member institutions responded to the survey. Across those institutions, 
^{style[font_weight=Bold]675} individual faculty members and ^{style[font_weight=Bold]1,124} 
students responded. At your institution, ^{style[font_weight=Bold]&faculty.} faculty and ^{style[font_weight=Bold]&students.} 
students responded." /
style = {font_size=14pt just=l width=100%};

run;

ods pdf close; 
ods listing; 

pdf_output.PNG

7 REPLIES 7
ballardw
Super User

Bold takes up more space. Even just the guard space involved between words in a proportional font.

 

I might suggest an approach other than bold, such as underline or italic or possibly even text color. But I suspect that width=100% may still result in some odd spacing.

 

I don't see a terrible difference when creating RTF output. Or in the RTF converted to PDF by Adobe.

 

I also note that having the start of the inline in the first column or the end of a line in the editor seems to contribute to some irregularity even in HTML.

NeilH
Obsidian | Level 7

@ballardw. thanks for the quick reply. I've bumped into the same problem with italics and underlining. So it's not specific to bold. And I do need to create a PDF directly.

ballardw
Super User

You might consider finding one of the fonts that supports a fontweight of semibold, create a new style that uses that font family and see if the semibold does the same thing.

 

Or give up on bolding text inline. Maybe present a small table instead of paragraph text. 

 

I do understand the frustration. I have worked on projects that were linking Word report documents to Excel pages for graphs and Access data base for text brought together by Mailmerge. Then we had to create a customized version of a PDF-like file that our printer required for actual printing. The driver required rendered things like bullet points differently depending on the version of Windows it was installed on. So instead of being able to share manual steps of the process across 5 staff we had only one computer that rendered the documents correctly.

NeilH
Obsidian | Level 7

It is a bit frustrating. : ) All good thoughts, but at this point, I'm checking to see if there's a way to correct the spacing with the bold, italics, ... w/o changing anything else about the text. From what I've seen in responses to a couple of past similar questions, there may not be a straightforward solution due to font incompatibilities, as you point out. But if someone has worked  it out, I'd welcome hearing. Thanks.

NeilH
Obsidian | Level 7

This simple addition suggested to me from SAS technical support did the trick - adding 'dpi=600' to the ods pdf statement like this:

 

ods pdf file="&folder&filename&extension" startpage=no dpi=600;

 

ballardw
Super User

@NeilH wrote:

This simple addition suggested to me from SAS technical support did the trick - adding 'dpi=600' to the ods pdf statement like this:

 

ods pdf file="&folder&filename&extension" startpage=no dpi=600;

 


Glad you found a solution.

 

A warning with high DPI settings like that. I have had instances where larger values of DPI ran into trouble rendering some graphs as the amount of memory used ran into a limit.

Sorting_it
Calcite | Level 5
This worked for you? I was having a similar issue, extraneous spaces, when I did the following:

P "In the data set, ^{style [color=red]&count_age_flag. (&PERCENTAGE_AGE_FLAG %)} of observations had invalid ages." / STYLE=[COLOR=black FONT_WEIGHT=BOLD FONTSIZE=10PT];

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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
  • 7 replies
  • 558 views
  • 2 likes
  • 3 in conversation