Dear Cynthia and other talented SAS users:
I am trying to get the footnote text to fit under a table I created with PROC REPORT, but, ODS makes my whole table split up and span several pages.
The table portion of my ideal output is supposed to look like the table that is on page one of the attached .rtf file. That table was produced by commenting out the "compute before _page_;" and "compute after;" statements at the end of the first PROC REPORT series of code.
When I 'un-comment' the "compute before _page_;" and "compute after;" statements, as is the case in the 2nd PROC REPORT series of code, the title and footnote text seems to make the table on page one turn into a massive table spanning several pages. in the attached .rtf file, this 2nd table spanning several pages is found after page 1 (on pages 2-6).
I will also point out that the column headings, and data values are of no importance. The goal is to get the footnote text and table title fit properly below, and above the table on page 1, respectively.
Also, how can I get the table on page 1 (the ideal table) to span from left margin to right margin? For some reason, it is not filling up the page from left or right?
I hope you all can help me.
Thanks.
proc contents data=sashelp.cars varnum; run;
proc print data=sashelp.cars (obs=10); run;
data test__
(
where=(roword<7)
)
;
length
grpord
roword
type1
brkvar
8
;
set sashelp.cars
(
drop=invoice
)
end=last;
retain grpord 1 brkvar 1;
array varc{*} $40 _character_;
array varn{*} 8 _numeric_;
array col {14} $40;
if _n_=1 then do;
type1=1;
roword+1;
col1="Variable";
do i=2 to dim(col);
col{i}=" ";
end;
output;
end;
type1=0;
roword+1;
do i = 1 to dim(varc);
col{i}=varc{i};
end;
do i=6 to dim(col);
col{i}=put(varn{i-1},10.);
end;
output;
keep
grpord
roword
type1
brkvar
col1-col14
;
rename type1=type;
run;
options nodate nonumber orientation=landscape;
title;
%let path=C:\Users\XXXX\Desktop;
ods rtf path="&path";
ods rtf file="ods_test.rtf";
ods escapechar='~';
proc report data=test__ nowd split='`';
column
grpord
roword
type
col1
("UYTEOAS"
("VV"
col2
)
("XX% UO"
col3
col4
cia
)
)
("ONIO CJIKLY"
("ZY"
col5
)
("XX% AB"
col6
col7
cio
)
)
("PJTYMNX"
("TN"
col8
)
("XX% AB"
col9
col10
cip
)
)
("LXRYNM"
("VS"
col11
)
("XX% AB"
col12
col13
cil
)
)
("~{raw \i Z}-jjjjj~{super a}"
col14
)
brkvar
;
define grpord/order noprint;
define roword/order noprint;
define type/order noprint;
define brkvar/noprint;
define col1/
display
" "
width=10
style(header)={cellwidth=0.5in}
style(column)={
just=l
};
define col2/
display
" "
width=10
style(header)={cellwidth=0.5in}
style(column)={
just=c
};
define col3/
noprint
" "
width=10
style(header)={cellwidth=0.5in}
style(column)={
just=c
};
define col4/
noprint
" "
width=10
style(header)={cellwidth=0.5in}
style(column)={
just=c
};
define cia/
computed
" "
width=10
style(header)={cellwidth=0.5in}
style(column)={
just=c
};
define col5/
display
" "
width=10
style(header)={cellwidth=0.5in}
style(column)={
just=c
};
define col6/
noprint
" "
width=10
style(header)={cellwidth=0.5in}
style(column)={
just=c
};
define col7/
noprint
" "
width=10
style(header)={cellwidth=0.5in}
style(column)={
just=c
};
define cio/
computed
" "
width=10
style(header)={cellwidth=0.5in}
style(column)={
just=c
};
define col8/
display
" "
width=10
style(header)={cellwidth=0.5in}
style(column)={
just=c
};
define col9/
noprint
" "
width=10
style(header)={cellwidth=0.5in}
style(column)={
just=c
};
define col10/
noprint
" "
width=10
style(header)={cellwidth=0.5in}
style(column)={
just=c
};
define cip/
computed
" "
width=10
style(header)={cellwidth=0.5in}
style(column)={
just=c
};
define col11/
display
" "
width=10
style(header)={cellwidth=0.5in}
style(column)={
just=c
};
define col12/
noprint
" "
width=10
style(header)={cellwidth=0.5in}
style(column)={
just=c
};
define col13/
noprint
" "
width=10
style(header)={cellwidth=0.5in}
style(column)={
just=c
};
define cil/
computed
" "
width=10
style(header)={cellwidth=0.5in}
style(column)={
just=c
};
define col14/
display
" "
width=10
style(header)={cellwidth=0.5in}
style(column)={
just=c
};
compute brkvar;
if type=0 then do;
call define('col1','style','style={leftmargin=12pt}');
end;
endcomp;
compute cia/character length=12;
if type=0 then
/*ci1=cats(col11,', ',col12);*/
cia=strip(col3)||', '||strip(col4);
else ci1=" ";
endcomp;
compute cio/character length=12;
if type=0 then
/*ci2=cats(col16,', ',col17); */
cio=strip(col6)||', '||strip(col7);
else ci2=" ";
endcomp;
compute cip/character length=12;
if type=0 then
/*ci1=cats(col11,', ',col12);*/
cip=strip(col9)||', '||strip(col10);
else ci1=" ";
endcomp;
compute cil/character length=12;
if type=0 then
/*ci2=cats(col16,', ',col17); */
cil=strip(col12)||', '||strip(col13);
else ci2=" ";
endcomp;
/*compute before _page_ /*/
/* style={just=l foreground=black font_size=10pt bordertopstyle=hidden borderrightstyle=hidden borderleftstyle=hidden};*/
/* line "Title text 1 Title text 1 Title text 1 Title text 1 Title text 1 Title text 1 Title text 1 Title text 1 Title text 1 Title text 1 Title text 1 Title text 1 Title text 1";*/
/*endcomp;*/
/**/
/*compute after /*/
/* style={just=l foreground=black font_size=10pt borderbottomstyle=hidden borderrightstyle=hidden borderleftstyle=hidden};*/
/* line "footnote line 1 footnote line 1 footnote line 1 footnote line 1 footnote line 1 footnote line 1 footnote line 1 footnote line 1 footnote line 1 footnote line 1 footnote line 1 footnote line 1 footnote line 1 footnote line 1 footnote line 1 footnote line 1 footnote line 1 footnote line 1 footnote line 1 footnote line 1 footnote";*/
/* line "footnote line 2 footnote line 2 footnote line 2 footnote line 2 footnote line 2 footnote line 2 footnote line";*/
/* line "footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 foo";*/
/*endcomp;*/
run;
proc report data=test__ nowd split='`';
column
grpord
roword
type
col1
("UYTEOAS"
("VV"
col2
)
("XX% UO"
col3
col4
cia
)
)
("ONIO CJIKLY"
("ZY"
col5
)
("XX% AB"
col6
col7
cio
)
)
("PJTYMNX"
("TN"
col8
)
("XX% AB"
col9
col10
cip
)
)
("LXRYNM"
("VS"
col11
)
("XX% AB"
col12
col13
cil
)
)
("~{raw \i Z}-jjjjj~{super a}"
col14
)
brkvar
;
define grpord/order noprint;
define roword/order noprint;
define type/order noprint;
define brkvar/noprint;
define col1/
display
" "
width=10
style(header)={cellwidth=0.5in}
style(column)={
just=l
};
define col2/
display
" "
width=10
style(header)={cellwidth=0.5in}
style(column)={
just=c
};
define col3/
noprint
" "
width=10
style(header)={cellwidth=0.5in}
style(column)={
just=c
};
define col4/
noprint
" "
width=10
style(header)={cellwidth=0.5in}
style(column)={
just=c
};
define cia/
computed
" "
width=10
style(header)={cellwidth=0.5in}
style(column)={
just=c
};
define col5/
display
" "
width=10
style(header)={cellwidth=0.5in}
style(column)={
just=c
};
define col6/
noprint
" "
width=10
style(header)={cellwidth=0.5in}
style(column)={
just=c
};
define col7/
noprint
" "
width=10
style(header)={cellwidth=0.5in}
style(column)={
just=c
};
define cio/
computed
" "
width=10
style(header)={cellwidth=0.5in}
style(column)={
just=c
};
define col8/
display
" "
width=10
style(header)={cellwidth=0.5in}
style(column)={
just=c
};
define col9/
noprint
" "
width=10
style(header)={cellwidth=0.5in}
style(column)={
just=c
};
define col10/
noprint
" "
width=10
style(header)={cellwidth=0.5in}
style(column)={
just=c
};
define cip/
computed
" "
width=10
style(header)={cellwidth=0.5in}
style(column)={
just=c
};
define col11/
display
" "
width=10
style(header)={cellwidth=0.5in}
style(column)={
just=c
};
define col12/
noprint
" "
width=10
style(header)={cellwidth=0.5in}
style(column)={
just=c
};
define col13/
noprint
" "
width=10
style(header)={cellwidth=0.5in}
style(column)={
just=c
};
define cil/
computed
" "
width=10
style(header)={cellwidth=0.5in}
style(column)={
just=c
};
define col14/
display
" "
width=10
style(header)={cellwidth=0.5in}
style(column)={
just=c
};
compute brkvar;
if type=0 then do;
call define('col1','style','style={leftmargin=12pt}');
end;
endcomp;
compute cia/character length=12;
if type=0 then
/*ci1=cats(col11,', ',col12);*/
cia=strip(col3)||', '||strip(col4);
else ci1=" ";
endcomp;
compute cio/character length=12;
if type=0 then
/*ci2=cats(col16,', ',col17); */
cio=strip(col6)||', '||strip(col7);
else ci2=" ";
endcomp;
compute cip/character length=12;
if type=0 then
/*ci1=cats(col11,', ',col12);*/
cip=strip(col9)||', '||strip(col10);
else ci1=" ";
endcomp;
compute cil/character length=12;
if type=0 then
/*ci2=cats(col16,', ',col17); */
cil=strip(col12)||', '||strip(col13);
else ci2=" ";
endcomp;
compute before _page_ /
style={just=l foreground=black font_size=10pt bordertopstyle=hidden borderrightstyle=hidden borderleftstyle=hidden};
line "Title text 1 Title text 1 Title text 1 Title text 1 Title text 1 Title text 1 Title text 1 Title text 1 Title text 1 Title text 1 Title text 1 Title text 1 Title text 1";
endcomp;
compute after /
style={just=l foreground=black font_size=10pt borderbottomstyle=hidden borderrightstyle=hidden borderleftstyle=hidden};
line "footnote line 1 footnote line 1 footnote line 1 footnote line 1 footnote line 1 footnote line 1 footnote line 1 footnote line 1 footnote line 1 footnote line 1 footnote line 1 footnote line 1 footnote line 1 footnote line 1 footnote line 1 footnote line 1 footnote line 1 footnote line 1 footnote line 1 footnote line 1 footnote";
line "footnote line 2 footnote line 2 footnote line 2 footnote line 2 footnote line 2 footnote line 2 footnote line";
line "footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 foo";
endcomp;
run;
ods rtf close;
Dear SAS community,
For those who might be interested in the solution to my 'follow-up' questions that I posed to Cynthia and Suzanne, I believe I was able to come up with a solution by modifying Suzanne's code by specifying the PRETEXT= and POSTTEXT= style elements in the REPORT statement STYLE option in conjunction with RTF control words to add a title text and footnote text, respectively.
Please see attached code for details.
Best wishes to all,
Varelle
title;
options orientation=landscape nonumber nodate leftmargin=1 in rightmargin=1 in ;
ods rtf file='test.rtf' style=mod_rtf;
/*ods rtf file="&path/ods_test.rtf";*/
/*bodytitle_aux */
ods escapechar='~';
proc report nowindows data=test__ split="`"
style=[
pretext="\ql\li0 Title text 1 Title text 1 Title text 1 Title text 1 Title text 1 Title text 1 Title text 1 Title text 1 Title text 1 Title text 1 Title text 1 Title text 1 Title text 1"
outputwidth=100%
/*frame=hsides rules=groups */
font_face="times new roman" font_size=10 pt
posttext="\ql\li0 footnote line 1 footnote line 1 footnote line 1 footnote line 1 footnote line 1 footnote line 1 footnote line 1 footnote line 1 footnote line 1 footnote line 1 footnote line 1 footnote line 1 footnote line 1 footnote line 1 footnote line 1 footnote line 1 footnote line 1 footnote line 1 footnote line 1 footnote line 1 footnote \line footnote line 2 \line footnote line 3"
protectspecialchars=off
]
style(header lines)=[font_face="times new roman"]
style(column)=[font_face="times new roman" cellwidth=0.5 in just=center] ;
column grpord roword type col1
("UYTEOAS"
("VV" col2) ("XX% UO" col3 col4 cia) ) ("ONIO CJIKLY"
("ZY" col5) ("XX% AB" col6 col7 cio) ) ("PJTYMNX"
("TN" col8) ("XX% AB" col9 col10 cip) ) ("LXRYNM"
("VS" col11) ("XX% AB" col12 col13 cil) ) ("~{raw \i Z}-jjjjj~{super a}" col14)
brkvar;
define grpord/order noprint;
define roword/order noprint;
define type/order noprint;
define brkvar/noprint;
define col1/ display " "
style(column)={just=l};
define col2/ display " "
style(column)={just=c};
define col3/ noprint " "
style(column)={just=c};
define col4/ noprint " "
style(column)={just=c};
define cia/ computed " "
style(column)={just=c};
define col5/ display " "
style(column)={just=c};
define col6/ noprint " "
style(column)={just=c};
define col7/ noprint " "
style(column)={just=c};
define cio/ computed " "
style(column)={just=c};
define col8/ display " "
style(column)={just=c};
define col9/ noprint " "
style(column)={just=c};
define col10/ noprint " "
style(column)={just=c};
define cip/ computed " "
style(column)={just=c};
define col11/ display " "
style(column)={just=c};
define col12/ noprint " "
style(column)={just=c};
define col13/ noprint " "
style(column)={just=c};
define cil/ computed " "
style(column)={just=c};
define col14/ display " "
style(column)={just=c};
compute brkvar;
if type=0 then
do;
call define('col1', 'style', 'style={leftmargin=12pt}');
end;
endcomp;
compute cia/character length=12;
if type=0 then
/*ci1=cats(col11,', ',col12);*/
cia=strip(col3)||', '||strip(col4);
else
ci1=" ";
endcomp;
compute cio/character length=12;
if type=0 then
/*ci2=cats(col16,', ',col17); */
cio=strip(col6)||', '||strip(col7);
else
ci2=" ";
endcomp;
compute cip/character length=12;
if type=0 then
/*ci1=cats(col11,', ',col12);*/
cip=strip(col9)||', '||strip(col10);
else
ci1=" ";
endcomp;
compute cil/character length=12;
if type=0 then
/*ci2=cats(col16,', ',col17); */
cil=strip(col12)||', '||strip(col13);
else
ci2=" ";
endcomp;
/* compute before _page_ / */
/* style={just=l foreground=black font_size=10pt bordertopstyle=hidden borderrightstyle=hidden borderleftstyle=hidden}; */
/* line "Title text 1 Title text 1 Title text 1 Title text 1 Title text 1 Title text 1 Title text 1 Title text 1 Title text 1 Title text 1 Title text 1 Title text 1 Title text 1"; */
/* endcomp; */
/* */
/* compute after / */
/* style={just=l foreground=black font_size=10pt borderbottomstyle=hidden borderrightstyle=hidden borderleftstyle=hidden}; */
/* line "footnote line 1 footnote line 1 footnote line 1 footnote line 1 footnote line 1 footnote line 1 footnote line 1 footnote line 1 footnote line 1 footnote line 1 footnote line 1 footnote line 1 footnote line 1 footnote line 1 footnote line 1 footnote line 1 footnote line 1 footnote line 1 footnote line 1 footnote line 1 footnote"; */
/* line "footnote line 2 footnote line 2 footnote line 2 footnote line 2 footnote line 2 footnote line 2 footnote line"; */
/* line "footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 foo"; */
/* endcomp; */
/*title j=l*/
/* "Title text 1 Title text 1 Title text 1 Title text 1 Title text 1 Title text 1 Title text 1 Title text 1 Title text 1 Title text 1 Title text 1 Title text 1 Title text 1"; */
/*footnote1 j=l */
/* "footnote line 1 footnote line 1 footnote line 1 footnote line 1 footnote line 1 footnote line 1 footnote line 1 footnote line 1 footnote line 1 footnote line 1 footnote line 1 footnote line 1 footnote line 1 footnote line 1 footnote line 1 footnote line 1 footnote line 1 footnote line 1 footnote line 1 footnote line 1 footnote"; */
/*footnote2 j=l*/
/* "footnote line 2 footnote line 2 footnote line 2 footnote line 2 footnote line 2 footnote line 2 footnote line"; */
/*footnote3 j=l*/
/* "footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 foo"; */
run;
ods rtf close;
Hi:
I'm not on a computer where I can run code right now. A few things are glaring to me. Using width= along with cellwidth makes no sense because WIDTH= is a LISTING only option that will be ignored by ODS RTF, but it is distracting. And you make your code unnecessarily long and hard to read by splitting the DEFINE and style override across several lines (8 lines) like this:
define col3/
noprint
" "
width=10
style(header)={cellwidth=0.5in}
style(column)={
just=c
};
instead of using just 3 lines like this:
define col3/ noprint " "
style(header)={cellwidth=0.5in}
style(column)={just=c};
I got rid of WIDTH= because you don't need it. I find the second example easier to read and more compact than the first example.
You did only show some of the relevant options, like orientation but not margins.
Also not clear is why you are NOT using the regular TITLE and FOOTNOTE statements for the actual TITLE and FOOTNOTES instead of pumping them into COMPUTE blocks.
I will try to take a closer look tomorrow. Maybe someone else has insight.
Cynthia
If you want the report to fill the width of the output, it seems like it would be easier to use STYLE(REPORT)={OUTPUTWIDTH=100%} on the PROC REPORT statement.
The BODYTITLE_AUX option on the ODS RTF FILE statement might treat the title and the footnotes as you wish. I had to use a modified style template to show the title and footnotes without the bold italic, which is the default for RTF.
proc contents data=sashelp.cars varnum;
run;
proc print data=sashelp.cars (obs=10);
run;
data test__
(where=(roword<7) );
length grpord roword type1 brkvar 8;
set sashelp.cars
(drop=invoice) end=last;
retain grpord 1 brkvar 1;
array varc{*} $40 _character_;
array varn{*} 8 _numeric_;
array col {14} $40;
if _n_=1 then
do;
type1=1;
roword+1;
col1="Variable";
do i=2 to dim(col);
col{i}=" ";
end;
output;
end;
type1=0;
roword+1;
do i=1 to dim(varc);
col{i}=varc{i};
end;
do i=6 to dim(col);
col{i}=put(varn{i-1}, 10.);
end;
output;
keep grpord roword type1 brkvar col1-col14;
rename type1=type;
run;
proc template;
define style mod_rtf;
parent=styles.rtf;
style fonts from fonts/
'TitleFont2' = ("<serif>, Times Roman",12pt,bold italic)
'TitleFont' = ("<serif>, Times Roman",10pt)
'StrongFont' = ("<serif>, Times Roman",10pt,bold)
'EmphasisFont' = ("<serif>, Times Roman",10pt,italic)
'FixedEmphasisFont' = ("<monospace>, Courier",9pt,italic)
'FixedStrongFont' = ("<monospace>, Courier",9pt,bold)
'FixedHeadingFont' = ("<monospace>, Courier",9pt,bold)
'BatchFixedFont' = ("SAS Monospace, <monospace>, Courier",6.7pt)
'FixedFont' = ("<monospace>, Courier",9pt)
'headingEmphasisFont' = ("<serif>, Times Roman",11pt,bold italic)
'headingFont' = ("<serif>, Times Roman",11pt,bold)
'docFont' = ("<serif>, Times Roman",10pt);
end;
options nodate nonumber orientation=landscape;
*%let path=C:\Users\XXXX\Desktop;
%let path=/folders/myfolders/RTF;
ods rtf file="&path/ods_test.rtf" bodytitle_aux style=mod_rtf;
ods escapechar='~';
proc report data=test__ nowd split='`'
style(report)={outputwidth=100%};
column grpord roword type col1
("UYTEOAS"
("VV" col2) ("XX% UO" col3 col4 cia) ) ("ONIO CJIKLY"
("ZY" col5) ("XX% AB" col6 col7 cio) ) ("PJTYMNX"
("TN" col8) ("XX% AB" col9 col10 cip) ) ("LXRYNM"
("VS" col11) ("XX% AB" col12 col13 cil) ) ("~{raw \i Z}-jjjjj~{super a}" col14)
brkvar;
define grpord/order noprint;
define roword/order noprint;
define type/order noprint;
define brkvar/noprint;
define col1/ display " "
style(column)={just=l};
define col2/ display " "
style(column)={just=c};
define col3/ noprint " "
style(column)={just=c};
define col4/ noprint " "
style(column)={just=c};
define cia/ computed " "
style(column)={just=c};
define col5/ display " "
style(column)={just=c};
define col6/ noprint " "
style(column)={just=c};
define col7/ noprint " "
style(column)={just=c};
define cio/ computed " "
style(column)={just=c};
define col8/ display " "
style(column)={just=c};
define col9/ noprint " "
style(column)={just=c};
define col10/ noprint " "
style(column)={just=c};
define cip/ computed " "
style(column)={just=c};
define col11/ display " "
style(column)={just=c};
define col12/ noprint " "
style(column)={just=c};
define col13/ noprint " "
style(column)={just=c};
define cil/ computed " "
style(column)={just=c};
define col14/ display " "
style(column)={just=c};
compute brkvar;
if type=0 then
do;
call define('col1', 'style', 'style={leftmargin=12pt}');
end;
endcomp;
compute cia/character length=12;
if type=0 then
/*ci1=cats(col11,', ',col12);*/
cia=strip(col3)||', '||strip(col4);
else
ci1=" ";
endcomp;
compute cio/character length=12;
if type=0 then
/*ci2=cats(col16,', ',col17); */
cio=strip(col6)||', '||strip(col7);
else
ci2=" ";
endcomp;
compute cip/character length=12;
if type=0 then
/*ci1=cats(col11,', ',col12);*/
cip=strip(col9)||', '||strip(col10);
else
ci1=" ";
endcomp;
compute cil/character length=12;
if type=0 then
/*ci2=cats(col16,', ',col17); */
cil=strip(col12)||', '||strip(col13);
else
ci2=" ";
endcomp;
/* compute before _page_ / */
/* style={just=l foreground=black font_size=10pt bordertopstyle=hidden borderrightstyle=hidden borderleftstyle=hidden}; */
/* line "Title text 1 Title text 1 Title text 1 Title text 1 Title text 1 Title text 1 Title text 1 Title text 1 Title text 1 Title text 1 Title text 1 Title text 1 Title text 1"; */
/* endcomp; */
/* */
/* compute after / */
/* style={just=l foreground=black font_size=10pt borderbottomstyle=hidden borderrightstyle=hidden borderleftstyle=hidden}; */
/* line "footnote line 1 footnote line 1 footnote line 1 footnote line 1 footnote line 1 footnote line 1 footnote line 1 footnote line 1 footnote line 1 footnote line 1 footnote line 1 footnote line 1 footnote line 1 footnote line 1 footnote line 1 footnote line 1 footnote line 1 footnote line 1 footnote line 1 footnote line 1 footnote"; */
/* line "footnote line 2 footnote line 2 footnote line 2 footnote line 2 footnote line 2 footnote line 2 footnote line"; */
/* line "footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 foo"; */
/* endcomp; */
title j=l
"Title text 1 Title text 1 Title text 1 Title text 1 Title text 1 Title text 1 Title text 1 Title text 1 Title text 1 Title text 1 Title text 1 Title text 1 Title text 1";
footnote1 j=l
"footnote line 1 footnote line 1 footnote line 1 footnote line 1 footnote line 1 footnote line 1 footnote line 1 footnote line 1 footnote line 1 footnote line 1 footnote line 1 footnote line 1 footnote line 1 footnote line 1 footnote line 1 footnote line 1 footnote line 1 footnote line 1 footnote line 1 footnote line 1 footnote";
footnote2 j=l
"footnote line 2 footnote line 2 footnote line 2 footnote line 2 footnote line 2 footnote line 2 footnote line";
footnote3 j=l
"footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 foo";
run;
proc report data=test__ nowd split='`'
style(report)={outputwidth=100%};
column grpord roword type col1
("UYTEOAS"
("VV" col2) ("XX% UO" col3 col4 cia) ) ("ONIO CJIKLY"
("ZY" col5) ("XX% AB" col6 col7 cio) ) ("PJTYMNX"
("TN" col8) ("XX% AB" col9 col10 cip) ) ("LXRYNM"
("VS" col11) ("XX% AB" col12 col13 cil) ) ("~{raw \i Z}-jjjjj~{super a}" col14)
brkvar;
define grpord/order noprint;
define roword/order noprint;
define type/order noprint;
define brkvar/noprint;
define col1/ display " "
style(column)={just=l};
define col2/ display " "
style(column)={just=c};
define col3/ noprint " "
style(column)={just=c};
define col4/ noprint " "
style(column)={just=c};
define cia/ computed " "
style(column)={just=c};
define col5/ display " "
style(column)={just=c};
define col6/ noprint " "
style(column)={just=c};
define col7/ noprint " "
style(column)={just=c};
define cio/ computed " "
style(column)={just=c};
define col8/ display " "
style(column)={just=c};
define col9/ noprint " "
style(column)={just=c};
define col10/ noprint " "
style(column)={just=c};
define cip/ computed " "
style(column)={just=c};
define col11/ display " "
style(column)={just=c};
define col12/ noprint " "
style(column)={just=c};
define col13/ noprint " "
style(column)={just=c};
define cil/ computed " "
style(column)={just=c};
define col14/ display " "
style(column)={just=c};
compute brkvar;
if type=0 then
do;
call define('col1', 'style', 'style={leftmargin=12pt}');
end;
endcomp;
compute cia/character length=12;
if type=0 then
/*ci1=cats(col11,', ',col12);*/
cia=strip(col3)||', '||strip(col4);
else
ci1=" ";
endcomp;
compute cio/character length=12;
if type=0 then
/*ci2=cats(col16,', ',col17); */
cio=strip(col6)||', '||strip(col7);
else
ci2=" ";
endcomp;
compute cip/character length=12;
if type=0 then
/*ci1=cats(col11,', ',col12);*/
cip=strip(col9)||', '||strip(col10);
else
ci1=" ";
endcomp;
compute cil/character length=12;
if type=0 then
/*ci2=cats(col16,', ',col17); */
cil=strip(col12)||', '||strip(col13);
else
ci2=" ";
endcomp;
run;
ods rtf close;
Screen shot of results:
Hi Suzanne,
Thanks so much for your reply.
If I may, I would like to ask you the following follow-up questions about the code and output you shared:
1. When I 'comment-out' the " style(report)={outputwidth=100%}" PROC REPORT option, the table appears as it did on page 1 of the output that I had supplied in my original post, but the footnote and title text aligns with the page margins as opposed to the table borders (right and left). Is there a way to use the TITLE and FOOTNOTE statements to align with the table margins, in the case where the table does not span from the entire space from left page margin to right page margin?
2. When I used the COMPUTE BLOCK with the LINE statement to produce footnote and title text, there is virtually no space between the table and the footnotes and title text. When using the TITLE and FOOTNOTE statements, it appears that there is a tiny bit of space between the title and footnote text and the table. Is there a way to eliminate these spaces between the top border of the table and the title text and between the bottom border of the table and the footnote text when producing title and footnote text with TITLE and FOOTNOTE statements, respectively?
3. From reading the documentation, it appears that the TITLE and FOOTNOTE statements add titles at the beginning of the first page of RTF output and footnotes at the end of the final page of RTF output. This is perfect for the case in which there is only one table produced in the output. But what if I want to produce 2 tables such that the title of table 1 is "Table 1" and the title of table 2 is "Table 2". Additionally, each table has it's own footnote text. Would it be possible to accommodate these requirements using the TITLE and FOOTNOTE statements with the ODS RTF destination and PROC REPORT? These requirements are why I originally chose to use a COMPUTE BLOCK with a LINE statements to produce titles and footnotes so that I could use the code to produce multiple tables with slightly different titles and footnotes all sent to one ODS RTF file.
Thanks again for your help.
Sincerely,
Varelle
Perhaps I misunderstood the question. The OUTPUTWIDTH= option seems like the easy way to make the table use the width of the page.
I don't have experience putting titles and footnotes in COMPUTE blocks in PROC REPORT.
If you want different titles and footnotes for different tables, issue different TITLE and FOOTNOTE statements. From a quick glance, it looked like your example was the same output twice. I'm nothing if not lazy, so I didn't do the TITLE and FOOTNOTE statements again for the second PROC REPORT.
Hi Suzanne,
Thanks so much for your help.
I think you did very much answer my original questions, for which I am grateful. Your approach just made me think of other scenarios, which is why I offered my follow-up questions.
I would not at all characterize you as lazy. Far from it -- your approach with using PROC TEMPLATE to modify title text as well as making my code appear more 'readable' obviously required a lot of effort. Thanks for all of that help.
Perhaps Cynthia might be able to answer my 'follow-up' questions regarding COMPUTE BLOCKS vs. TITLE and FOOTNOTE statements.
Thanks again and best wishes.
Sincerely,
Varelle
Hi Cynthia,
Suzanne was able to provide a solution that mostly resolved the questions in my original post. The code she shared and her approach made me think of other questions that are related to my original post:
1. When I 'comment-out' the " style(report)={outputwidth=100%}" PROC REPORT option, the table appears as it did on page 1 of the output that I had supplied in my original post, but the footnote and title text aligns with the page margins as opposed to the table borders (right and left). Is there a way to use the TITLE and FOOTNOTE statements to align with the table borders (left and right), in the case where the table does not span from the entire space from left page margin to right page margin?
2. When I used the COMPUTE BLOCK with the LINE statement to produce footnote and title text, there is virtually no space between the table and the footnotes and title text. When using the TITLE and FOOTNOTE statements, it appears that there is a tiny bit of space between the title and footnote text and the table. Is there a way to eliminate these spaces between the top border of the table and the title text and between the bottom border of the table and the footnote text when producing title and footnote text with TITLE and FOOTNOTE statements, respectively?
3. From reading the documentation, it appears that the TITLE and FOOTNOTE statements add titles at the beginning of the first page of RTF output and footnotes at the end of the final page of RTF output. This is perfect for the case in which there is only one table produced in the output. But what if I want to produce 2 tables such that the title of table 1 is "Table 1" and the title of table 2 is "Table 2". Additionally, each table has it's own footnote text. Would it be possible to accommodate these requirements using the TITLE and FOOTNOTE statements with the ODS RTF destination and PROC REPORT? These requirements are why I originally chose to use a COMPUTE BLOCK with a LINE statements to produce titles and footnotes so that I could use the code to produce multiple tables with slightly different titles and footnotes all sent to one ODS RTF file.
Perhaps you might have insight to share regarding these questions.
Many thanks,
Varelle
Dear SAS community,
For those who might be interested in the solution to my 'follow-up' questions that I posed to Cynthia and Suzanne, I believe I was able to come up with a solution by modifying Suzanne's code by specifying the PRETEXT= and POSTTEXT= style elements in the REPORT statement STYLE option in conjunction with RTF control words to add a title text and footnote text, respectively.
Please see attached code for details.
Best wishes to all,
Varelle
title;
options orientation=landscape nonumber nodate leftmargin=1 in rightmargin=1 in ;
ods rtf file='test.rtf' style=mod_rtf;
/*ods rtf file="&path/ods_test.rtf";*/
/*bodytitle_aux */
ods escapechar='~';
proc report nowindows data=test__ split="`"
style=[
pretext="\ql\li0 Title text 1 Title text 1 Title text 1 Title text 1 Title text 1 Title text 1 Title text 1 Title text 1 Title text 1 Title text 1 Title text 1 Title text 1 Title text 1"
outputwidth=100%
/*frame=hsides rules=groups */
font_face="times new roman" font_size=10 pt
posttext="\ql\li0 footnote line 1 footnote line 1 footnote line 1 footnote line 1 footnote line 1 footnote line 1 footnote line 1 footnote line 1 footnote line 1 footnote line 1 footnote line 1 footnote line 1 footnote line 1 footnote line 1 footnote line 1 footnote line 1 footnote line 1 footnote line 1 footnote line 1 footnote line 1 footnote \line footnote line 2 \line footnote line 3"
protectspecialchars=off
]
style(header lines)=[font_face="times new roman"]
style(column)=[font_face="times new roman" cellwidth=0.5 in just=center] ;
column grpord roword type col1
("UYTEOAS"
("VV" col2) ("XX% UO" col3 col4 cia) ) ("ONIO CJIKLY"
("ZY" col5) ("XX% AB" col6 col7 cio) ) ("PJTYMNX"
("TN" col8) ("XX% AB" col9 col10 cip) ) ("LXRYNM"
("VS" col11) ("XX% AB" col12 col13 cil) ) ("~{raw \i Z}-jjjjj~{super a}" col14)
brkvar;
define grpord/order noprint;
define roword/order noprint;
define type/order noprint;
define brkvar/noprint;
define col1/ display " "
style(column)={just=l};
define col2/ display " "
style(column)={just=c};
define col3/ noprint " "
style(column)={just=c};
define col4/ noprint " "
style(column)={just=c};
define cia/ computed " "
style(column)={just=c};
define col5/ display " "
style(column)={just=c};
define col6/ noprint " "
style(column)={just=c};
define col7/ noprint " "
style(column)={just=c};
define cio/ computed " "
style(column)={just=c};
define col8/ display " "
style(column)={just=c};
define col9/ noprint " "
style(column)={just=c};
define col10/ noprint " "
style(column)={just=c};
define cip/ computed " "
style(column)={just=c};
define col11/ display " "
style(column)={just=c};
define col12/ noprint " "
style(column)={just=c};
define col13/ noprint " "
style(column)={just=c};
define cil/ computed " "
style(column)={just=c};
define col14/ display " "
style(column)={just=c};
compute brkvar;
if type=0 then
do;
call define('col1', 'style', 'style={leftmargin=12pt}');
end;
endcomp;
compute cia/character length=12;
if type=0 then
/*ci1=cats(col11,', ',col12);*/
cia=strip(col3)||', '||strip(col4);
else
ci1=" ";
endcomp;
compute cio/character length=12;
if type=0 then
/*ci2=cats(col16,', ',col17); */
cio=strip(col6)||', '||strip(col7);
else
ci2=" ";
endcomp;
compute cip/character length=12;
if type=0 then
/*ci1=cats(col11,', ',col12);*/
cip=strip(col9)||', '||strip(col10);
else
ci1=" ";
endcomp;
compute cil/character length=12;
if type=0 then
/*ci2=cats(col16,', ',col17); */
cil=strip(col12)||', '||strip(col13);
else
ci2=" ";
endcomp;
/* compute before _page_ / */
/* style={just=l foreground=black font_size=10pt bordertopstyle=hidden borderrightstyle=hidden borderleftstyle=hidden}; */
/* line "Title text 1 Title text 1 Title text 1 Title text 1 Title text 1 Title text 1 Title text 1 Title text 1 Title text 1 Title text 1 Title text 1 Title text 1 Title text 1"; */
/* endcomp; */
/* */
/* compute after / */
/* style={just=l foreground=black font_size=10pt borderbottomstyle=hidden borderrightstyle=hidden borderleftstyle=hidden}; */
/* line "footnote line 1 footnote line 1 footnote line 1 footnote line 1 footnote line 1 footnote line 1 footnote line 1 footnote line 1 footnote line 1 footnote line 1 footnote line 1 footnote line 1 footnote line 1 footnote line 1 footnote line 1 footnote line 1 footnote line 1 footnote line 1 footnote line 1 footnote line 1 footnote"; */
/* line "footnote line 2 footnote line 2 footnote line 2 footnote line 2 footnote line 2 footnote line 2 footnote line"; */
/* line "footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 foo"; */
/* endcomp; */
/*title j=l*/
/* "Title text 1 Title text 1 Title text 1 Title text 1 Title text 1 Title text 1 Title text 1 Title text 1 Title text 1 Title text 1 Title text 1 Title text 1 Title text 1"; */
/*footnote1 j=l */
/* "footnote line 1 footnote line 1 footnote line 1 footnote line 1 footnote line 1 footnote line 1 footnote line 1 footnote line 1 footnote line 1 footnote line 1 footnote line 1 footnote line 1 footnote line 1 footnote line 1 footnote line 1 footnote line 1 footnote line 1 footnote line 1 footnote line 1 footnote line 1 footnote"; */
/*footnote2 j=l*/
/* "footnote line 2 footnote line 2 footnote line 2 footnote line 2 footnote line 2 footnote line 2 footnote line"; */
/*footnote3 j=l*/
/* "footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 footnote line 3 foo"; */
run;
ods rtf close;
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.
Ready to level-up your skills? Choose your own adventure.