The SAS Output Delivery System and reporting techniques

PROC ODSTEXT RTF margins vary for different statements

Accepted Solution Solved
Reply
Contributor sm4
Contributor
Posts: 51
Accepted Solution

PROC ODSTEXT RTF margins vary for different statements

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!



Accepted Solutions
Solution
‎02-20-2018 01:15 PM
Super User
Posts: 13,924

Re: PROC ODSTEXT RTF margins vary for different statements

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

View solution in original post


All Replies
SAS Super FREQ
Posts: 9,426

Re: PROC ODSTEXT RTF margins vary for different statements

[ Edited ]

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.
proportional_vs_fixed_font.png
cynthia

Contributor sm4
Contributor
Posts: 51

Re: PROC ODSTEXT RTF margins vary for different statements

Posted in reply to Cynthia_sas

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.

Solution
‎02-20-2018 01:15 PM
Super User
Posts: 13,924

Re: PROC ODSTEXT RTF margins vary for different statements

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

Contributor sm4
Contributor
Posts: 51

Re: PROC ODSTEXT RTF margins vary for different statements

Works perfectly!!!! Seriously spent hours wondering what was going on, thanks a million.

☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 4 replies
  • 224 views
  • 0 likes
  • 3 in conversation