The SAS Output Delivery System and reporting techniques

formatting multiple line statements in proc report

Reply
Contributor
Posts: 21

formatting multiple line statements in proc report

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;

Contributor
Posts: 21

formatting multiple line statements in proc report

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

SAS Super FREQ
Posts: 8,868

Re: formatting multiple line statements in proc report

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
Contributor
Posts: 21

Re: formatting multiple line statements in proc report

Posted in reply to Cynthia_sas

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

SAS Super FREQ
Posts: 8,868

Re: formatting multiple line statements in proc report

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
Ask a Question
Discussion stats
  • 4 replies
  • 1551 views
  • 3 likes
  • 2 in conversation