Hello,
I have yet another PROC ODSTEXT question.
Basically: the margins in my output RTF file are different for different statements. For example,
proc template; define style styles.hello; class usertext / font_size = 11pt font_face = Georgia; style paragraph from usertext; class body / topmargin = 1.0in leftmargin = 0.75in rightmargin = 0.75in; end; run; ods rtf file= "mars_ods3.rtf" style= styles.hello startpage= on; ods escapechar= '^'; proc odstext; p "^S={leftmargin=0.25in}xxxxxxxxxxxxxxxx ^{style [font_weight=bold font_size=12pt]Contact:} ^{style [font_size=10pt]Xxxxxxx Xxxxxxx (000) 000-0000}"; p "^S={leftmargin=0.25in}xxxxxxxxxxxxxxxxx ^{style [font_weight=bold font_size=12pt foreground=white]Contact:} ^{style [font_size=10pt]Xxxxxxxx Xxxxxxx (000) 000-0000}"; p "^S={leftmargin=0.25in}xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"; run; ods rtf close;
(the white text is to get things to align, though they don't here, since I replaced names with x's.)
The 3rd statement has perfect margins, but the first two (for me, at least) wrap around after (000). I can't understand why this happens, since the lines are short. But after a lot of experimenting, I found a workaround for this particular example:
ods rtf file= "folder/hello.rtf" style= styles.hello startpage= on; ods escapechar= '^'; proc odstext; p "^S={leftmargin=0.25in}xxxxxxxxxxxxxxxx ^{style [font_weight=bold font_size=12pt]Contact:} ^{style [font_size=10pt]Xxxxxxx Xxxxxxx (000) 000-0000}^{style [font_size= 0.01pt foreground=white] ................}"; p "^S={leftmargin=0.25in}xxxxxxxxxxxxxxxx ^{style [font_weight=bold font_size=12pt foreground=white]Contact:} ^{style [font_size=10pt]Xxxxxxxx Xxxxxxx (000) 000-0000}^{style [font_size= 0.01pt foreground=white] ................}"; p "^S={leftmargin=0.25in}xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"; run; ods rtf close;
Now the first two lines do not wrap around. But this keeps happening for other text too and I can't keep tailoring workarounds to different text.
Any ideas? All I can think of is that my proc template class body statement must need to be tweaked in some way.
Thank you!
See if this helps:
proc template; define style styles.hello; parent=styles.rtf; class usertext / font_size = 11pt font_face = "Georgia" ; style paragraph from usertext; class body / topmargin = 1.0in leftmargin = 0.75in rightmargin = 0.75in; end; run;
I think that the issue is you didn't really have anything that knew how to determine ends of lines using the page information.
With the parent style added to your style I at least get different line ends that seem to honor the margins better though you have too many spaces on the second line
Hi:
It was my understanding that the margins you set for the BODY style in the template were for the whole document. The leftmargin you set in the PROC ODSTEXT will be at the cell level.
I do not see you using a fixed pitch font like Courier. A period in a fixed pitch font will take up more space than a period in a proportional font. See the screen shot below.
cynthia
Hello,
Thanks for your reply.
Yes, I am trying to automate an organization document - so I am restricted to recreating exactly the formatting of the original. Thus I need to use the Georgia font and I need to indent those two lines only (there is a lot of other text that is not indented and uses only the BODY style). I could have removed the leftmargin in the example here, but left it in case it is a partial source of the problem so that someone can point that out.
I admit I'm not clear on the font issue, being not too knowledgeable about these things. Should I change the font for the example? Ultimately I will need to use Georgia.
See if this helps:
proc template; define style styles.hello; parent=styles.rtf; class usertext / font_size = 11pt font_face = "Georgia" ; style paragraph from usertext; class body / topmargin = 1.0in leftmargin = 0.75in rightmargin = 0.75in; end; run;
I think that the issue is you didn't really have anything that knew how to determine ends of lines using the page information.
With the parent style added to your style I at least get different line ends that seem to honor the margins better though you have too many spaces on the second line
Works perfectly!!!! Seriously spent hours wondering what was going on, thanks a million.
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!
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.