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-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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
  • 1 reply
  • 1287 views
  • 0 likes
  • 2 in conversation