BookmarkSubscribeRSS Feed
mcook
Quartz | Level 8

Given the dataset Temp1 from the code below,  I am trying to generate a table with header borders like this  ( I manually added the borders in Word).

Capture.PNG

data Temp1;
	input Col1 $ Col2 Col3 Col4 Col5 Col6;
	datalines;
Set1 2 3 4 5 6
;
run;

ODS RTF File="&FilePath.\HeaderTest.rtf";
ODS Escapechar='^';
options nodate nonumber;

proc report data=Temp1
	Style(Report)=[rules=None Frame=HSides]
	style(Header)=[background=lightgrey]
	style(Column)=[just=c];
	Columns ('^{Style[borderbottomwidth=0
					borderrightwidth=0.1pt
					borderrightcolor=black]}'(Col1)) 
			('^{Style[borderbottomwidth=0]}'(Col2)) 
			('^{Style[borderleftwidth=0.1pt
						borderleftcolor=black
						borderrightwidth=0.1pt
						borderrightcolor=black]Span1}'(Col3 Col4)) 
		('Span2'(Col5 Col6));
	define Col1 / display
style(Header)=[bordertopwidth=0
/*		bordertopcolor=lightgrey*/
				];
	define Col2 / analysis 
		style(Header)=[bordertopwidth=0
/*		bordertopcolor=lightgrey*/
		borderleftwidth=0.1pt
		borderleftcolor=black];
	define Col3 / analysis 
		style(Header)=[
		borderleftwidth=0.1pt
		borderleftcolor=black
		bordertopwidth=0.1pt
		bordertopcolor=black];
	define Col4 / analysis 
		style(Header)=[
		borderleftwidth=0.1pt
		borderleftcolor=black
		bordertopwidth=0.1pt
		bordertopcolor=black];
	define Col5 / analysis 
		style(Header)=[
		borderleftwidth=0.1pt
		borderleftcolor=black
		bordertopwidth=0.1pt
		bordertopcolor=black];
	define Col6 / analysis 
		style(Header)=[
		borderleftwidth=0.1pt
		borderleftcolor=black				
		bordertopwidth=0.1pt
		bordertopcolor=black];
run;

ODS RTF Close;

Notice I used escape char to create an empty spanning header over each of Col1 and Col2.  Both those spanning headers have a borderbottomwidth=0 ,and Col1 and Col2 headers have bordertopwidth=0.  

But this outputs the following

border0.PNG

even with the border set to 0 from top and bottom, it still shows the border.

Then if I uncomment the 'bordertopcolor=lightgrey' for Col1 and Col2, it removes the border (or just masks it), but leaves a gap in the vertical column. (circled below, hopefully visible)

BorderGrey.jpg

Why does the bordertop/bottom width=0 not remove the border and not result in a  solid vertical line?  Is it that the spanning header borders are done with ODS EscapeChar?  Is there a way around this? or is there another way to extend Col1 and Col2 headers up to the top frame, rather than generate dummy spanning headers?   

1 REPLY 1
hlnquynh
Obsidian | Level 7

Hi,

 

Sorry for multiple replies..

I tried this code and it worked. A thin dash line is visible but it won't affect the printing.

 

proc report data=Temp1 split = '@'
  Style(Report)=[rules=None Frame=HSides cellspacing=0 ]
  style(Header)=[background=lightgrey borderleftwidth=0.1pt borderleftcolor=black borderrightwidth=0.1pt borderrightcolor=black ]
  style(Column)=[just=c bordertopcolor=black bordertopwidth=0.1pt borderleftcolor=white borderrightcolor=white borderbottomwidth=0.1pt borderbottomcolor=black];
Columns
("^S={borderleftwidth=0.1pt borderleftcolor=black}" (col1))
("^S={borderleftwidth=0.1pt borderleftcolor=black}" (col2))
("^S={borderbottomwidth=0.1pt borderbottomcolor=black borderbottomstyle=solid}Span1" (Col3 Col4))
("^S={borderbottomwidth=0.1pt borderbottomcolor=black borderbottomstyle=solid}Span2" (Col5 Col6));
define Col1 /display;
define Col2 /analysis;
define Col3 /analysis;
define Col4 /analysis;
define Col5 /analysis;
define Col6 /analysis;
run;

sas-innovate-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and save with the early bird rate—just $795!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 1 reply
  • 2033 views
  • 0 likes
  • 2 in conversation