hi,
I am able to generate a table with 2 layers of spanned headers, as the following example:
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.
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;
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 | ||
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
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
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
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.