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

Hello,

Before when I used to create my output using the traditional SAS monospace output, the blank spaces to the left were preserved and the line breaks were created, and my AE output was similar to the output below. I've now converted my outputs to RTF, and now the output in the report (for the column of interest) is either to the left, to the right or in the center. Can you please let me know how I can add indents to my RTF output? Also can you please let me know how I can also add the line breaks into the output too? Please see below for the example dataset and code.

MedDRA System Organ Class                                                           
  Preferred Term                                                                 
    CTCAE Grade                        

-------------------------------------------------------------------------------------------                                    

                                                                                                                      
ANY SYSTEM /  ANY TERM                                                                                                
    Total (3 + 4 + 5)                                                     
    3                                                                        
    4                                                                        
    5                                                                        
                                                                                                                      
BLOOD AND LYMPHATIC SYSTEM DISORDERS                                         
  Neutropenia                                                                                                         
    Total (3 + 4 + 5)                                                        
    3                                                                               
    4                                                                        
    5                                                                                                  

          

data test;
  input @1 mycat $40. ptermord;
  cards;
ANY SYSTEM /  ANY TERM                  1
Total (3 + 4 + 5)                       1
3                                       1
4                                       1
5                                       1
BLOOD AND LYMPHATIC SYSTEM DISORDERS    2
Neutropenia                             2
Total (3 + 4 + 5)                       2
3                                       2
4                                       2
5                                       2
;
run;

* Creating indents *;

ods rtf file = "test.rtf";

data test2;
  set test;
  if _n_ in (2, 3, 4, 5, 8, 9, 10, 11) then mycat = "    "||mycat;
run;

proc report data=test2 headline headskip split="¬" nowd missing style(report)=[whitespace=pre_wrap NOBREAKSPACE= OFF];
    column MyCat ptermord;
    define MyCat    / display left width=73 format=$200. left flow id "MedDRA System Organ Class¬  Preferred Term¬    CTCAE Grade" style(column)=[cellwidth=75% WHITESPACE=PRE textalign = _UNDEF_];
    define ptermord / order order=internal noprint;

    break after ptermord / SKIP ;
run;

ods rtf close;

Many thanks in advance!

1 ACCEPTED SOLUTION

Accepted Solutions
Cynthia_sas
SAS Super FREQ

Hi:  There are a few different ways to indent when you are using ODS RTF.

1) use INDENT= style override

2) use LEFTMARGIN= style override

3) use RTF control strings

 
        Line breaks are the same:

1) use ODS ESCAPECHAR and the {NEWLINE} ESCAPECHAR function

2) use RTF control strings.
   

Some examples in the program below. More examples in this paper http://www2.sas.com/proceedings/forum2008/173-2008.pdf in example 1 and example 8.

Cynthia

    

ods listing close;

ods rtf file='c:\temp\indent_text.rtf' startpage=no;

ods escapechar='^';

proc report data=sashelp.class

     style(report)={width=100%};

title 'showing indent and leftmargin';

define name / order 'The Header for Name^{newline 2}with a line break';

compute name;

  if name = 'Alfred' or name = 'Janet' then do;

    call define(_col_,'style','style={leftmargin=.50in}');

  end;

  else if name = 'Barbara' or name = 'John' then do;

    call define(_col_,'style','style={indent=60}');

  end;

endcomp;

compute after/style={just=l};

  line 'This is an example of using ^{newline 1} a line break escapechar function within PROC REPORT';

endcomp;

run;

 

ods rtf close;

View solution in original post

5 REPLIES 5
Cynthia_sas
SAS Super FREQ

Hi:  There are a few different ways to indent when you are using ODS RTF.

1) use INDENT= style override

2) use LEFTMARGIN= style override

3) use RTF control strings

 
        Line breaks are the same:

1) use ODS ESCAPECHAR and the {NEWLINE} ESCAPECHAR function

2) use RTF control strings.
   

Some examples in the program below. More examples in this paper http://www2.sas.com/proceedings/forum2008/173-2008.pdf in example 1 and example 8.

Cynthia

    

ods listing close;

ods rtf file='c:\temp\indent_text.rtf' startpage=no;

ods escapechar='^';

proc report data=sashelp.class

     style(report)={width=100%};

title 'showing indent and leftmargin';

define name / order 'The Header for Name^{newline 2}with a line break';

compute name;

  if name = 'Alfred' or name = 'Janet' then do;

    call define(_col_,'style','style={leftmargin=.50in}');

  end;

  else if name = 'Barbara' or name = 'John' then do;

    call define(_col_,'style','style={indent=60}');

  end;

endcomp;

compute after/style={just=l};

  line 'This is an example of using ^{newline 1} a line break escapechar function within PROC REPORT';

endcomp;

run;

 

ods rtf close;

djrisks
Barite | Level 11

Thank you for this Cynthia, this works! 🙂

I was just wondering do you know if it's possible if I can add RTF control words to the dataset, and then produce the report using the RTF control words that are in the dataset? This is just because typically I have added the spaces/indents to the dataset that was used in Proc Report. If not it's fine and I will start producing the indents the way you suggested.

Thank you.

Cynthia_sas
SAS Super FREQ

Hi:

  The downside of the RTF control string approach is that you cannot, then, send the output to PDF or HTML without changing the data. I have had many students who went down the RTF control string approach, only to discover that, later, they needed to also produce the same report for a web page or for Acrobat Reader. If they had used ODS techniques that work in most destinations, then one program would have sufficed.

  If you do insert the RTF control strings in the data, then you MUST turn the style attributes PROTECTSPECIALCHARS=OFF for the elements (probably DATA or HEADER) where you have added  the strings. Otherwise, SAS and ODS might try to "protect" the special characters used in the control strings.

cynthia

djrisks
Barite | Level 11

Thank you Cynthia 🙂

Ksharp
Super User

4) use PRETEXT='     '    and  ASIS=ON  style override

5) use escapchar   ~_~_~_~_   before the variable.

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
  • 5 replies
  • 12473 views
  • 11 likes
  • 3 in conversation