The SAS Output Delivery System and reporting techniques

Controlling borders using Proc Report and ODS RTF (black fails, control individual header cells)

Accepted Solution Solved
Reply
Occasional Contributor
Posts: 8
Accepted Solution

Controlling borders using Proc Report and ODS RTF (black fails, control individual header cells)

[ Edited ]

I have two questions. Using SAS 9.4 on Windows here.

First I have a very short program which prints out a table which is almost correct. I would like the top left cell to not have a top line drawn. I suspect there might be a way to have a fake no print column as first column and control printing for various cells based on its value but I have not figured out how to do this.
 
Second, I had trouble drawing borders. Some of these borders did NOT draw when I set border color to black, but worked fine when I used orange. This seems like a bug, but perhaps I am misunderstanding what is happening.

I have included bogus data and all code necessary to draw table. I hope someone who has worked with PROC Report for years might be able to enlighten me. This is the first time I have used it.

(Edited, added macro for bcolor to assist in testing different border colors. Also included output files for bcolor=red, orange, and black. Perhaps it is a defective version of Microsoft Word which is making it look like the borders are not there for the black version?)

 

DATA RTF_EXAMPLE3;
INPUT Parameter ERI CombFlc a1M b2M crp plr albumin il6;
CARDS;
1 1 .6 .7 .3 .4 .1 .2 .3
2 .3 1 .6 .7 .3 .4 .1 .2
3 .2 .3 1 .6 .7 .3 .4 .1
4 .1 .2 .3 1 .6 .7 .3 .4
5 .4 .1 .2 .3 1 .6 .7 .3
6 .3 .4 .1 .2 .3 1 .6 .7
7 .7 .3 .4 .1 .2 .3 1 .6
8 .6 .7 .3 .4 .1 .2 .3 1
RUN;

proc format;
 value cp
 1='ERI'
 2='Combined FLC'
 3="~{unicode 03B1}1M"
 4="~{unicode 03B2}2M"
 5='cpr'
 6='PRL'
 7='albumin'
 8='IL-6';
run;

 

%LET bcolor=red;

 

ODS HTML CLOSE;

ODS ESCAPECHAR='~';

ods rtf file="Y:\Users\Slavik\rptbss3.rtf" columns=1;

proc report nowindows data=RTF_EXAMPLE3

style(report)=[rules=none frame=void]

style(header)=[just=center font_weight=bold background=white borderbottomcolor=&bcolor bordertopcolor=&bcolor borderrightcolor=&bcolor protectspecialchars=off];

/* column Parameter eri ("Middle Molecules~{super 2} \brdrl\brdrs\brdrw10\brsp0 \brdrt\brdrs\brsp0 \brdrr\brdrs\brsp0" combFlc a1M b2M)

("Markers of Inflammation~{super 3} \brdrl\brdrs\brdrt\brdrs\brdrr\brdrs" crp plr albumin il6); */

column Parameter eri ("Middle Molecules~{super 2}" combFlc a1M b2M)

("Markers of Inflammation~{super 3}" crp plr albumin il6);

define Parameter/group "Parameter" format=cp. order=internal

style(header)=[borderrightcolor=&bcolor]

style(column)=[borderrightcolor=&bcolor];

define eri/display "ERI~{super 1}"

style(header)=[borderrightcolor=&bcolor just=c]

style(column)=[borderrightcolor=&bcolor just=d];

define combFlc/display "Combined FLC"

style(header)=[borderrightcolor=white cellwidth=1.25in just=c]

style(column)=[just=c];

define a1M/display "~{unicode 03B1}1M"

style(header)=[borderrightcolor=white just=c]

style(column)=[just=c];

define b2M/display "~{unicode 03B2}2M"

style(header)=[borderrightcolor=&bcolor just=c]

style(column)=[borderrightcolor=&bcolor just=c];

define crp/display "CRP"

style(header)=[borderrightcolor=white just=c]

style(column)=[just=c];

define plr/display "PLR"

style(header)=[borderrightcolor=white just=c]

style(column)=[just=c];

define albumin/display "albumin"

style(header)=[borderrightcolor=white just=c]

style(column)=[just=c];

define il6/display "IL-6"

style(header)=[borderrightcolor=&bcolor just=c]

style(column)=[borderrightcolor=&bcolor just=c];

compute before Parameter;

if Parameter=. THEN CALL DEFINE(_col_, "Style", "STYLE=[bordertopcolor=&bcolor]");

ENDCOMP;

/* This is to add line at bottom of table */

compute Parameter;

if Parameter = 8 THEN CALL DEFINE(_col_, "Style", "STYLE=[borderbottomcolor=&bcolor]");

endcomp;

compute eri;

if Parameter = 8 THEN CALL DEFINE(_col_, "Style", "STYLE=[borderbottomcolor=&bcolor]");

endcomp;

compute combFlc;

if Parameter = 8 THEN CALL DEFINE(_col_, "Style", "STYLE=[borderbottomcolor=&bcolor]");

endcomp;

compute a1M;

if Parameter = 8 THEN CALL DEFINE(_col_, "Style", "STYLE=[borderbottomcolor=&bcolor]");

endcomp;

compute b2M;

if Parameter = 8 THEN CALL DEFINE(_col_, "Style", "STYLE=[borderbottomcolor=&bcolor]");

endcomp;

compute crp;

if Parameter = 8 THEN CALL DEFINE(_col_, "Style", "STYLE=[borderbottomcolor=&bcolor]");

endcomp;

compute plr;

if Parameter = 8 THEN CALL DEFINE(_col_, "Style", "STYLE=[borderbottomcolor=&bcolor]");

endcomp;

compute albumin;

if Parameter = 8 THEN CALL DEFINE(_col_, "Style", "STYLE=[borderbottomcolor=&bcolor]");

endcomp;

compute il6;

if Parameter = 8 THEN CALL DEFINE(_col_, "Style", "STYLE=[borderbottomcolor=&bcolor]");

endcomp;

run;

Attachment
Attachment
Attachment

Accepted Solutions
Solution
‎03-17-2017 01:29 PM
Occasional Contributor
Posts: 8

Re: Controlling borders using Proc Report and ODS (black fails, control individual header cells)

Using one of Cynthia's examples I tried again. This time it seems to work. Here is the revised code for printing the report, the data parts are the same as previously.

/* Macro to add bottom border to column */

%macro add_bottom_border(column_name);

   compute &column_name;

   if Parameter = 8 THEN CALL DEFINE(_col_, "Style", "STYLE=[borderbottomcolor=black]");

   endcomp;

%mend add_bottom_border;

 

/* Macro to add bottom border to table */

%macro add_bottom_border_to_table;

   %add_bottom_border(Parameter);

   %add_bottom_border(eri);

   %add_bottom_border(combFlc);

   %add_bottom_border(a1M);

   %add_bottom_border(b2M);

   %add_bottom_border(crp);

   %add_bottom_border(plr);

   %add_bottom_border(albumin);

   %add_bottom_border(il6);

%mend add_bottom_border;

 

ods rtf file="Y:\Users\Slavik\bss4.rtf";

ods escapechar='^';

proc report nowindows data=RTF_EXAMPLE3

   style(header)={background=white fontweight=bold};

   column (/*"^{style[textdecoration=underline]The Topmost header}"*/

            ("^{style[borderleftcolor=white bordertopcolor=white]} " Parameter ERI)

            ("Middle Molecules^{super 2}" combFlc a1M b2M)

            ("Markers of Inflammation^{super 3}" crp plr albumin il6)

      );

   define Parameter/group "Parameter" format=cp. order=internal

      style(header)=[borderleftcolor=white]

      style(column)=[borderleftcolor=white borderbottomcolor=white];

   define eri/display "ERI^{super 1}"

      style(header)=[just=c]

      style(column)=[borderbottomcolor=white just=d];

   define combFlc/display "Combined FLC"

      style(header)=[cellwidth=1.25in just=c]

      style(column)=[borderrightcolor=white borderbottomcolor=white just=c];

   define a1M/display "^{unicode 03B1}1M"

      style(header)=[just=c]

      style(column)=[borderrightcolor=white borderbottomcolor=white just=c];

   define b2M/display "^{unicode 03B2}2M"

      style(header)=[just=c]

      style(column)=[borderbottomcolor=white just=c];

   define crp/display "CRP"

      style(header)=[just=c]

      style(column)=[borderrightcolor=white borderbottomcolor=white just=c];

   define plr/display "PLR"

      style(header)=[just=c]

      style(column)=[borderrightcolor=white borderbottomcolor=white just=c];

   define albumin/display "albumin"

      style(header)=[just=c]

      style(column)=[borderrightcolor=white borderbottomcolor=white just=c];

   define il6/display "IL-6"

      style(header)=[just=c]

      style(column)=[borderbottomcolor=white just=c];

     %add_bottom_border_to_table;

run;

View solution in original post


All Replies
Super User
Posts: 11,141

Re: Controlling borders using Proc Report and ODS (black fails, control individual header cells)

When I run your code with your data the "top left" cell, in fact none of the top row have a top line. You may need to be more explicit about what you need if that isn't quite what you mean.

 

Similarly, if I replace 'orange' with 'black' the lines are drawn in black that were orange.

 

You may want to try specifying a style in the ods rtf statement. The default being used for RTF may be having issues. Do you see any notes related to style in the log?

 

Also many times if you attempt to change borderrightcolor you may need to set borderleftcolor on the cell to the right.

 

I'm not quite sure what you are attempting for a final appearance but I would guess that perhaps you may want to try one of the JOURNAL styles and remove most of your style code in the body of the report.

Occasional Contributor
Posts: 8

Re: Controlling borders using Proc Report and ODS (black fails, control individual header cells)

[ Edited ]

I have added RTF files which are being produced by my system. Maybe it is a Microsoft issue. The top left cell which has no text in has a top border. Our analyst does not want it to have one. The rest of the top row is showing top borders (above Middle Molecules and Markers of Inflammation). Perhaps you see something different on your systems. We have Microsoft Office 2010 installed.

 

Thanks!

Super User
Posts: 11,141

Re: Controlling borders using Proc Report and ODS (black fails, control individual header cells)

The whole report is a table. The elements are cells. All of them have "borders" as defined by a cell border in an rtf table. Or the equivalent in HTML or PDF.

 

I would wonder what the concern is about the prescence/non-presence may be. Unless this is a parameter file to be read by some other program for a non-wordprocessing process I don't see an issue as long as RTF is the desired output.

If you want a plain text output then a different approach such as Proc Printto may work (though you may have issues with superscript and unicode output with that approach) but as long as the output is RTF you are going to get tables/cells with borders visible or not.

Occasional Contributor
Posts: 8

Re: Controlling borders using Proc Report and ODS (black fails, control individual header cells)

Thank you for that clarification. We need RTF output. I have tried all the built-in RTF reports. Our analyst has borders she wants. I am trying to eliminate certain borders that show in in the standard reports. The table printed by the code I submitted is almost perfect. Just need the top border of the top left cell removed, but I have not been able to remove that border without removing other borders that the analyst likes. This is not my preference but it is my job to produce reports.

Solution
‎03-17-2017 01:29 PM
Occasional Contributor
Posts: 8

Re: Controlling borders using Proc Report and ODS (black fails, control individual header cells)

Using one of Cynthia's examples I tried again. This time it seems to work. Here is the revised code for printing the report, the data parts are the same as previously.

/* Macro to add bottom border to column */

%macro add_bottom_border(column_name);

   compute &column_name;

   if Parameter = 8 THEN CALL DEFINE(_col_, "Style", "STYLE=[borderbottomcolor=black]");

   endcomp;

%mend add_bottom_border;

 

/* Macro to add bottom border to table */

%macro add_bottom_border_to_table;

   %add_bottom_border(Parameter);

   %add_bottom_border(eri);

   %add_bottom_border(combFlc);

   %add_bottom_border(a1M);

   %add_bottom_border(b2M);

   %add_bottom_border(crp);

   %add_bottom_border(plr);

   %add_bottom_border(albumin);

   %add_bottom_border(il6);

%mend add_bottom_border;

 

ods rtf file="Y:\Users\Slavik\bss4.rtf";

ods escapechar='^';

proc report nowindows data=RTF_EXAMPLE3

   style(header)={background=white fontweight=bold};

   column (/*"^{style[textdecoration=underline]The Topmost header}"*/

            ("^{style[borderleftcolor=white bordertopcolor=white]} " Parameter ERI)

            ("Middle Molecules^{super 2}" combFlc a1M b2M)

            ("Markers of Inflammation^{super 3}" crp plr albumin il6)

      );

   define Parameter/group "Parameter" format=cp. order=internal

      style(header)=[borderleftcolor=white]

      style(column)=[borderleftcolor=white borderbottomcolor=white];

   define eri/display "ERI^{super 1}"

      style(header)=[just=c]

      style(column)=[borderbottomcolor=white just=d];

   define combFlc/display "Combined FLC"

      style(header)=[cellwidth=1.25in just=c]

      style(column)=[borderrightcolor=white borderbottomcolor=white just=c];

   define a1M/display "^{unicode 03B1}1M"

      style(header)=[just=c]

      style(column)=[borderrightcolor=white borderbottomcolor=white just=c];

   define b2M/display "^{unicode 03B2}2M"

      style(header)=[just=c]

      style(column)=[borderbottomcolor=white just=c];

   define crp/display "CRP"

      style(header)=[just=c]

      style(column)=[borderrightcolor=white borderbottomcolor=white just=c];

   define plr/display "PLR"

      style(header)=[just=c]

      style(column)=[borderrightcolor=white borderbottomcolor=white just=c];

   define albumin/display "albumin"

      style(header)=[just=c]

      style(column)=[borderrightcolor=white borderbottomcolor=white just=c];

   define il6/display "IL-6"

      style(header)=[just=c]

      style(column)=[borderbottomcolor=white just=c];

     %add_bottom_border_to_table;

run;

☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 5 replies
  • 367 views
  • 0 likes
  • 2 in conversation