BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
sm4
Quartz | Level 8 sm4
Quartz | Level 8

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!


1 ACCEPTED SOLUTION

Accepted Solutions
ballardw
Super User

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

4 REPLIES 4
Cynthia_sas
SAS Super FREQ

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

sm4
Quartz | Level 8 sm4
Quartz | Level 8

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.

ballardw
Super User

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

sm4
Quartz | Level 8 sm4
Quartz | Level 8

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

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

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
  • 4 replies
  • 1342 views
  • 1 like
  • 3 in conversation