BookmarkSubscribeRSS Feed
Chang
Quartz | Level 8

hi,

 

I am able to generate a table with 2 layers of spanned headers, as the following example:

 

SAS_spanned_headers_01_2_levels.png

I would like to add another header on top of NU1-NU2 (N=132), NU2-NU3 (N=20) and NU1-NU3 (N=22), as the following example. Notice there gaps between the three middle layer headers are preserved.

 

SAS_spanned_headers_02_3_levels.png

Here is my code for generating the table with 2 layer spanned headers. My script "\brdrb\brdrdot\brdrw5\brdrcf1" in the column statement is a bit awkard. Hope there is a better way to achieve the same effect on the header text. Any suggestion would be appreciated. Thanks

 

 

/*----------------------------------------import data into SAS-----------------------------------------*/

data tem._NU_manuscript01_table01	;
	set &tDat_cronbach_ICC_SPHERE12.	;
	gap01='';	/*add gap01, gap02 for inserting blank in PROC REPORT*/
	gap02='';
	gap03="";
	gap04="";
	TT=1; /*insert this variable for breaking pages*/
run;

/*-------------------------Add titles and footnotes--------------------------------------------------------------------*/

/*change a procedure label*/
/*ods proclabel="&tTitle_cronbach_ICC_SPHERE12."	;*/
 
/*first node kept and used in table of contents*/
title4 J=L /*this is SAS data set name*/
		font='Times New Roman' 
		h=10pt "Data Source: &tDat_cronbach_ICC_SPHERE12." 
	;

title5 J=L /*this is the table title*/
		font='Times New Roman' 
		h=10pt "&tableTitle1."
	;  
footnote j=l /*this is the footnote*/
			 font='Times New Roman' 
			 h=10pt "Program Name: &tScr_cronbach_ICC_SPHERE12.			Programmer: Chang			Date:%sysfunc(date(),worddate18.)"	
	;
/*----------------------------------------add table body-----------------------------------------------------------*/

proc report	data=tem._NU_manuscript01_table01
					contents=""  /*remove default 2nd node*/
					nowd 
					split='|'
					style(report)={
								   width=100%  
								   cellpadding=8px
								   font_face='Times New Roman' 
								   font_size=10pt 
								   background = TRANSPARENT}
				    style(header)={just=center /*left */ 
								   font_weight=bold 
								   font_face='Times New Roman' 
								   font_size=10pt 
								   font_style=roman 
								   protectspecialchars = OFF 
								   background = TRANSPARENT}
					 style(column)={font_face='Times New Roman' 
									font_size=10pt 
									background = TRANSPARENT}
     ;

/*The COLUMN statement is used to list each report column*/
column 
	itemOmit number_of_items 
	("\brdrb\brdrdot\brdrw5\brdrcf1 Internal consistency" sample_size cronbach_alpha )
    gap01 /*insert a gap between columns with two-level headers*/

	("\brdrb\brdrdot\brdrw5\brdrcf1 NU1-NU2 (N=132) " NU1nNU2_ICC_95CI NU1nNU2_ICC_pvalue)
    gap02 /*insert a gap between columns with two-level headers*/

	("\brdrb\brdrdot\brdrw5\brdrcf1 NU2-NU3 (N=20)" NU2nNU3_ICC_95CI NU2nNU3_ICC_pvalue)
    gap03 /*insert a gap between columns with two-level headers*/

	("\brdrb\brdrdot\brdrw5\brdrcf1 NU1-NU3 (N=22)" NU1nNU3_ICC_95CI NU1nNU3_ICC_pvalue)
    gap04 /*insert a gap between columns with two-level headers*/
 		;

/*Each column, in turn, has a DEFINE statement that describes how that column is created and formatted.*/
%def_display(	cVar=itemOmit,				cName=SPHERE12 item,	cWide=6 cm, headerAlign=left, colAlign=left);
%def_display(	cVar=number_of_items,	cName=Number of items,		cWide=1.5 cm, colAlign=left);
%def_display(	cVar=sample_size,			cName=Sample size,			cWide=1.5 cm, colAlign=left);
%def_display(	cVar=cronbach_alpha,		cName=Cronbach alpha,		cWide=1.5 cm, colAlign=left);

%def_display(	cVar=NU1nNU2_ICC_95CI,		cName=ICC,		cWide=3 cm, colAlign=left);
%def_display(	cVar=NU1nNU2_ICC_pvalue,		cName=p value,	cWide=1.5 cm, colAlign=left);

%def_display(	cVar=NU2nNU3_ICC_95CI,		cName=ICC,		cWide=3 cm, colAlign=left);
%def_display(	cVar=NU2nNU3_ICC_pvalue,		cName=p value,	cWide=1.5 cm, colAlign=left);

%def_display(	cVar=NU1nNU3_ICC_95CI,		cName=ICC,		cWide=3 cm, colAlign=left);
%def_display(	cVar=NU1nNU3_ICC_pvalue,		cName=p value,	cWide=1.5 cm, colAlign=left);

/*define all the gap variables*/
%def_display(	cVar=gap01	,cName=			,isFmt=N	,cFmt=					,cWide=0.2%);
%def_display(	cVar=gap02	,cName=			,isFmt=N	,cFmt=					,cWide=0.2%);
%def_display(	cVar=gap03	,cName=			,isFmt=N	,cFmt=					,cWide=0.2%);
%def_display(	cVar=gap04	,cName=			,isFmt=N	,cFmt=					,cWide=0.2%);

compute after _page_ /style={just=l 
							 font_size=10pt 
							 font_face='Times New Roman'  
							 borderbottomcolor=white 
							 bordertopcolor=black}	;	
	line 	"&tableFootnote1.";	
endcomp;
run;

5 REPLIES 5
Cynthia_sas
SAS Super FREQ
Hi:
I'm not sure what you're asking. I do see the 2 layers of spanned header in your top screen shot. The title of your post asks about 3 layers of spanned header, but then you don't show WHAT the 3rd header is, it might be what you show in red in the 2nd screen shot, but that looks like a piece of a data table, not a piece of the report. Are you trying to add what is in red??

Why not use style=journal and textdecoration=underline???

cynthia
Chang
Quartz | Level 8

hi Cynthia,

 

Yes I am asking for 3 layer spanned headers. To illustrate what I want, I edited an excel file and copied the text there as a picture. I marked the header in red just to make it noticeable. It doesn't need to be colored in my table.

 

  test and retest reliability      
NU1-NU2 (N=132)   NU2-NU3 (N=20)   NU1-NU3 (N=22)
ICC p value   ICC p value   ICC p value
               
Cynthia_sas
SAS Super FREQ

Hi:

  Well, the key will be coding the column statement and getting the parentheses nested correctly. This example uses SASHELP.CARS and the JOURNAL style, as shown -- to do more than 3 headers.

cynthia

underline_header_report.png

Chang
Quartz | Level 8

hi Cynthia,

 

thanks for the code. [textdecoration=underline] generates an underline at the length of the text. But I wish the line under test and retest reliability will cover the 3 groups at its lower level as

 

SAS_spanned_headers_3layers_dashlines.png

 

If the line length of [textdecoration=underline...] cannot be changed, is it possible to edit my old code ("\brdrb\brdrdot\brdrw5\brdrcf1 header text") to generate solid underlines? You can see all my lines are dash lines.

 

Thanks

Cynthia_sas
SAS Super FREQ
Hi, Chang:
Text decoration is meant to only underline the text in the cell. The commands you are inserting are RTF control strings:
"\brdrb\brdrdot\brdrw5\brdrcf1 header text"

It's been awhile since I did RTF using the Microsoft controls, but I think that your issue is with the
\brdrb = bottom border
\brdrdot = dotted border
\brdrw5 = not sure I think this is border width for RTF (in twips)
\brdrcf1 = not sure I think this is color for border

Since the \brdr... commands are Microsoft RTF spec, you'll have to investigate what there should be instead of \brdrdot.

Here's a page with the RTF spec:
http://hackipedia.org/File%20formats/RTF,%20Rich%20Text%20Format/RTF%20v1.9.1.doc.pdf

I believe it is under Paragraph formatting for borders...approximately page 85-90.

cynthia

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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
  • 7714 views
  • 0 likes
  • 2 in conversation