Search code examples
sassas-macro

How to change the line (______) under the table to dotted line under the heading in the table (---) in SAS?


I want to change the line (_____________) under the heading of the table to dotted line (---------) under the heading of the table in proc report step. I tried using options formchar still its not working for me. Can you please help me ? If data is required, i can send you in chat since the data is confidential

proc template;  
  %** Courier 9pt **;
   define style Styles.ods_9pt;
        parent=styles.rtf;
        replace fonts/
          'TitleFont2' = ("Courier New",9pt,Bold )         
          'TitleFont' = ("Courier New",9pt,Bold )          
          'FootnoteFont' = ("Courier New",9pt )       
          'StrongFont' = ("Courier New",9pt )         
          'EmphasisFont' = ("Courier New",9pt )
          'FixedEmphasisFont' = ("Courier New",9pt )
          'FixedStrongFont' = ("Courier New",9pt)
          'FixedHeadingFont' = ("Courier New",9pt, Bold)
          'BatchFixedFont' = ("Courier New",9pt,Bold )
          'FixedFont' = ("Courier New",9pt )
          'headingEmphasisFont' = ("Courier New",9pt,Bold )
          'headingFont' = ("Courier New",9pt,Bold )        
          'docFont' = ("Courier New",9pt );
         replace document from container    /   
          asis = on
          protectspecialchars=off;
        replace SystemFooter from TitlesAndFooters /
          asis = on
          protectspecialchars = on
          font= Fonts('FootnoteFont');         
         replace systemtitle from titlesandfooters/
          asis = on
          protectspecialchars=off;   
         replace body from document /   
            asis = on; 
        replace color_list
          "Colors used in the default style" /
          'link'= blue
          'bgH'= white
          'fg' = black
          'bg' = white;         
        replace Table from output /
          Background=_UNDEF_                                                
          cellpadding = 0pt   
          Rules=groups
          Frame=void;
        style Header from Header /
          Background=_undef_;
        style Rowheader from Rowheader /
          Background=_undef_;
        replace pageno from titlesandfooters/
          Foreground=white;
   end;
   
ods listing;  
options papersize='LETTER' orientation=landscape topmargin = '3.61cm' bottommargin = '3.61cm' 
        leftmargin = '2.54cm' rightmargin = '2.54cm' nodate nonumber missing=.;
ods rtf file="/home/u000000/sasuser.v94/Listings/listing_Demo.rtf" style=styles.ods_9pt nogtitle nogfootnote;
ods escapechar = '~';
options formchar='|_---|+|---+=|-/\<>*'
options validvarname=any;
options pageno=1;
proc report data=newb nowd headline headskip split='*';
    column num mypage TRT01A SITE BRTHDTC AGE SEX ETHNIC HEIGHTBL WEIGHTBL;
    define num/ noprint;
    *break after num/skip;
    define mypage /order noprint; 
    break after mypage / page; 
    define TRT01A/'Treatment' order descending center style(column)={width=1in};
    define SITE/'Site Id.*Unique Subject Id.' center style(column)={width=1in};
    define BRTHDTC/'Date of*Birth' center style(column)={width=1in};
    define AGE/'Age (YEARS)*[1]' center style(column)={width=1in};
    define SEX/'Sex' center style(column)={width=1in};
    define ETHNIC/'Ethnicity' center style(column)={width=1in};
    define HEIGHTBL/'Height*(cm)' center style(column)={width=1in};
    define WEIGHTBL/'Weight*(kg)'center style(column)={width=1in};
    *compute after TRT01A;
    *line '';
    *endcomp;
    title1 j=l height=10pt font="Courier New" "Protocol: XXX" ;
    title3 j=l height=10pt font="Courier New" "Population :XXX" j=r 'Page ^{​​​​​​​thispage}​​​​​​​ of ^{​​​​​​​lastpage}​​​​​​​';
    title4;
    title5 j=c height=10pt font="Courier New" "Listing";
    title6 j=c height=10pt font="Courier New" "Listing of Demographic Characteristics";
    title7;
    footnote1 j = l height=10pt font="Courier New" "20NOV2020 10:42";
 run;
ods rtf close;
ods listing;

@Reeza: can you help me with this?


Solution

  • Way 1

    Add a line to the report.

    ods rtf file='report.rtf' style=ods_9pt;
    
    data class;
      set sashelp.class;
      page = 1;
    run;
    
    proc report data=class
      style(header) = [BorderBottomStyle=hidden]
    ;
      title;
      where name < 'H';
      columns page name age sex height weight;
      define page / order noprint;
      compute before page;
        line '-----------------------------------------------------------';
      endcomp;
    run;
    
    ods _all_ close;
    

    enter image description here

    Way 2

    You can manipulate the report column headers by injecting destination specific characters. You will also need to hide the header bottom border.

    Example:

    Change your style definition, replace

    style Header from Header / Background=_undef_;
    

    to

    style Header from Header / Background=_undef_ borderbottomstyle=hidden;
    

    and in the Proc REPORT, change the column headers to contain additional raw characters to be injected into the rtf table cell.

    define TRT01A / 
      'Treatment*~{dest [RTF] ~{raw -------}}'
      order descending center style(column)={width=1in};
    

    Trick (LISTING)

    There is an ODS LISTING trick for REPORT:

    • If a split line is two of the same formchar characters, they will be repeated across the column width.
    * ODS listing only;
    Proc REPORT ...;
    ...
        define TRT01A / 
          'Treatment*--`
          order descending center;
    ...