The SAS Output Delivery System and reporting techniques

spacing with in-line format changes (ODS -> pdf)

Reply
Occasional Contributor
Posts: 13

spacing with in-line format changes (ODS -> pdf)

I am using ODS to write a pdf report.  I have some words which need to be underlined.  I find when I use in-line formatting to underline the words, ODS is usually but not always inserting 3 or 4 blank spaces before the underlined text.   I have similar issues with italics and bold, but it's the underlines which are killing me.

The code is specifically stating the font each time because the template is set for the correct font for table cells and I have not had the time to figure out whether body text outside of table cells has a different style format and if so, what.

In the process of trying to capture the output to post here, I found this is another example of SAS rendering text twice.  This gives dark "bold-ish" double-strike text in the pdf.  Once I managed to select and copy it I found the SAS forumns web page won't let me paste it with formatting anyway, so I had to type an approximation of the output.

For instance, the 2 lines:

ods pdf text="^S={just=left font=('Calibri',12PT)}Major complications and major complications including death are specifically defined in ^S={font('Calibri',12PT)textdecoration=underline just=left}Appendix D^S={font=('Calibri',12PT)}. Patients were excluded from all complications";

ods pdf text="^S={just=left font=('Calibri',12PT)}modeling if they died within two days, if time to death was unknown, or if complications were unknown.";

produce output which looks like this (typed by me, since the interface won't let me copy it without messing up the format):

Major complications and major complications including death are specifically defined in      Appendix D. Patients were excluded from all complications

modeling if they dies within two days, if time to death was unknown, or if complications were unknown.


Anyone know if there is a way to make an inline font transition without spacing issues?  I tried not specifying jurtification, and justification=left to no avail.

SAS Super FREQ
Posts: 8,820

Re: spacing with in-line format changes (ODS -> pdf)

Hi:

  My suggestion is that you open a track with Tech Support. I switched from the "original" style ESCAPECHAR to the "new" style of ESCAPECHAR and discovered that I got different results with different fonts. See attached screen shot for SAS 9.4. This is probably the type of issue that needs to be tracked and reported to Tech Support. BTW, I prefer to put my long text strings into Macro variables, which I did here &TXT1 thru &TXT4 -- and then I only needed 1 ODS PDF TEXT= statement and It is easier to see the nested style specifications. One of the reasons for the new syntax for in-line style formatting was that you could not nest style specifications in the original syntax. In my test, only the Helvetica looked correct.
    

Cynthia

title;
ods pdf file='c:\temp\use_esc_new.pdf' startpage=no;
ods escapechar='^';

 

%let txt1 = 1 - Times New Roman and major complications including death are specifically defined in;
%let txt2 = Appendix D;
%let txt3 = . Patients were excluded from all complications modeling if they died within two days,;
%let txt4 = if time to death was unknown, or if complications were unknown.;

  
ods pdf text=
"^{style[just=left font_face='Times New Roman' font_size=12pt]&txt1%str( ) ^{style[textdecoration=underline]&txt2}&txt3 &txt4}";

    

proc print data=sashelp.class(obs=2);
run;

    

%let txt1 = 2 - Helvetica and major complications including death are specifically defined in;
ods pdf text=
"^{style[just=left font_face='Helvetica' font_size=12pt]&txt1%str( ) ^{style[textdecoration=underline]&txt2}&txt3 &txt4}";

proc print data=sashelp.class(obs=2);
run;

   

%let txt1 = 3 - Calibri and major complications including death are specifically defined in;
ods pdf text=
"^{style[just=left font_face='Calibri' font_size=12pt]&txt1%str( ) ^{style[textdecoration=underline]&txt2}&txt3 &txt4}";

proc print data=sashelp.class(obs=2);
run;

   

%let txt1 = 4 - Albany AMT and major complications including death are specifically defined in;
ods pdf text=
"^{style[just=left font_face='Albany AMT' font_size=12pt]&txt1%str( ) ^{style[textdecoration=underline]&txt2}&txt3 &txt4}";

proc print data=sashelp.class(obs=2);
run;
ods _all_ close;


diff_fonts_diff_results.png
Occasional Contributor
Posts: 13

Re: spacing with in-line format changes (ODS -> pdf)

Thanks, Cynthia.  We just went into validation and I may not get a chance to fuss with it anymore this cycle.  I'm working with inherited code and learning formatting the hard way.  Your examples are exactly what I need to think about how to redesign this mess and drag it into the present day. 

I know they had a LOT of trouble with Ariel a year ago, which is why we switched to Calibri.  I believe that was in an earlier version of SAS.  We are using 9.4 now.  I have already had one go-around with tech support about the doublestrike issues.  They are aware of it but it is not at the top of their list.

Do you know the name of the style element for text written that way?  I'm not sure whether it uses

'docFont'  like table cells do, or whether it uses something else.

SAS Super FREQ
Posts: 8,820

Re: spacing with in-line format changes (ODS -> pdf)

Hi, the style element that controls ODS TEXT is UserText, as shown in the program below.
      

  There has always been a problem with the Arial font being a Microsoft font and if you just used the "simple" font name Arial, Acrobat Reader would use Helvetica instead. The way to get Arial is to specify the font name as "Arial Unicode MS" -- the "official" Unicode . I have doubts about Calibri -- isn't that a Microsoft-written font?
      

Cynthia


ods path work.tmp(update) sasuser.templat(update) sashelp.tmplmst(read);
   
proc template;
  define style newpdf;
  parent=styles.printer;
    class usertext /
       color=purple
    fontweight=bold
    fontsize=18pt
    font_face='Times New Roman'
    textalign=center;
  end;
run;
   
ods pdf file='c:\temp\use_esc.pdf' startpage=no style=newpdf;
ods escapechar='^';
ods pdf text="Some Text ^{style[textdecoration=underline]Appendix D} and some more text.";

proc print data=sashelp.class(obs=2);
run;
ods pdf close;

Occasional Contributor
Posts: 13

Re: spacing with in-line format changes (ODS -> pdf)

Thank you, Cynthia!  You have told me 2 things now I have not been able to track down on my own.  Knowing "UserText" will simplify my life a lot.  I don't know about the politics of MS fonts, but now I know to start learning.  The boss hates Times New Roman, but we have some latitude to pick a font she finds acceptable.

Ask a Question
Discussion stats
  • 4 replies
  • 838 views
  • 6 likes
  • 2 in conversation