BookmarkSubscribeRSS Feed
AUTigers
Calcite | Level 5

Hello,

What i am trying to do is to indent multiple message at the end of proc report output. each line has different length. i want each of them start at the same position( the just=left or right will not work for my report). it seems like you can not indent individually the message created by Lines statement. my quesiton is is there any simple options or any tricks we can use to make each message form each line statement starts at different position. below is the sample code to demonstrade what i am trying to accomplish. thank you for your help.

ods rtf;

proc report data=sashelp.class nowd

style(lines)={font_family=Arial font_size=10pt};

column _all_;

compute after;

line "(*ESC*)S={indent=1in Font_weight=bold}this is first line (*ESC*)S={}";

line "(*ESC*)S={indent=1.5in }this is second line (*ESC*)S={}";

line "(*ESC*)S={indent=2in }this is 3rd line (*ESC*)S={}";

endcomp;

run;

ods rtf close;

4 REPLIES 4
AUTigers
Calcite | Level 5

For now, I just pad different length of blanks in front of each line and set ASIS to ON. it works but is not what i really want to do. I am looking for some thing simple.

Thanks!

Yu

Cynthia_sas
SAS Super FREQ

Hi:

  If you can use INDENT= as a style override, you should be able to use LEFTMARGIN=, too. You want all the text to line up at the same starting point, right? The screen shot was created with the program below.

cynthia

ods listing close;

ods rtf file='c:\temp\tryindent.rtf';

 

proc report data=sashelp.class(obs=3) nowd

     style(lines)={fontfamily=Arial font_size=10pt leftmargin=.25in just=l};

column _all_;

compute after;

   line "this is first line";

   line "this is second line";

   line "this is 3rd line";

endcomp;

run;

  

ods rtf close;


use_leftmargin.jpg
AUTigers
Calcite | Level 5

Hi, Cynthia,

Leftmargin works great when all lines start at same location. Is it possible to make each line to start at their own location? i tried to apply different leftmargin to each line, but no effect can be seen. it seems like inly the first style override will be taken into account, the rest are simply ignored.

Thanks!

Yu

Cynthia_sas
SAS Super FREQ

Hi, Thanks for clarifying.

It wasn't clear to me whether you wanted each line to be indented separately, or wanted them all to line up.

The issue with LEFTMARGIN is that your 3 LINE statements are writing to 1 single cell in the COMPUTE AFTER block. I believe that a single cell can only have 1 value for margin. If you changed your code to have some extra (fake) break lines, then you could write a LINE with each break and each LINE would get a single cell whose margin could be changed.

However, there is a method for your 3 LINE statements in COMPUTE AFTER. If your destination of interest is RTF, then you can use RTF-specific control strings (defined by Microsoft) that insert a TAB character into the beginning of each line. The code below produced the attached screenshot. When you use RTF control strings with your ODS RTF destination, you must turn the style attribute PROTECTSPECIALCHARS=OFF so that ODS does not "touch" or try to "protect" the control strings that you are inserting into the RTF document. Generally, the characters used by RTF control strings are \ and sometimes, you need to surround text with { and }. Be very careful with RTF control strings. One mismatched \ or { will cause the output file to be unreadable by Word. \tab is fairly safe to use. Just remember that \tab will NOT work with ODS HTML, ODS PDF or other destinations. It's for RTF only.

cynthia

ods rtf file='c:\temp\tryindent2.rtf';

 

proc report data=sashelp.class(obs=3) nowd

     style(lines)={fontfamily=Arial font_size=10pt leftmargin=.25in

                   just=l protectspecialchars=off};

title '2) use TAB with RTF Control String';

column _all_;

compute after;

   line "this is first line";

   line "\tab{this is second line}";

   line "\tab\tab{this is 3rd line}";

endcomp;

run;

  

ods rtf close;


tab_rtf_control.jpg

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