I recently came across the production of tables using proc report and ods. These tables have 12-13 lines of footnotes and some times bigger than 262 characters. I have gone through the SAS community for the best option i thought to produce the footnotes in this situation is keeping the "one footnote statement" and use the long lines of footnotes with use of "^n" ods escapechar and "noquotelenmax". however when I run this code normally, every thing in footnote aligned properly, but when I run in batch mode footnote is all over the place. Is there a solution for this? is any other easy option for long footnotes more than 10! other than using the compute blocks. Please let me know your suggestions. Thanks
ods results;
ODS RTF FILE="/folders/myfolders/TABLES/class.RTF";
ods escapechar="^";
options ls=190 NOQUOTELENMAX;
proc report data=sashelp.class nowd headskip split="?" ;
column Obs name sex age height weight ;
define sex / width=3 center ;
define age / width=5 ;
define height / format=6.1 ;
define weight / format=6.1 ;
define obs / computed ;
compute obs ;
count+1 ;
obs=count ;
endcomp ;
title2 'PROC REPORT, again' ;
footnote1 j=l "I would like to have a long foot note";
Footnote2 j = l "By default, PROC REPORT does not display an observation number column, which could be added with a computed variable. Also, note that the Height and Weight columns do not display consistently. This could be remedied by
adding a DEFINE statement for each of these columns and specifying a format^n
COMPUTE block for OBS (beginning with the COMPUTE OBS and ending with the ENDCOMP statement) specifies
how the column is populated. First, a counter, COUNT, is incremented with each pass through the data.^n The value of
COUNT is retained similar to a DATA step. The current value of the counter is then assigned to OBS.";
run ;
ods rtf close;
If you don't need the Footnote behavior, i.e. placing footnote into the footer area of a document, you might experiment with Proc ODSTEXT to create long text after a table.
Instead of
Footnote2 j = l "By default, PROC REPORT does not display an observation number column, which could be added with a computed variable. Also, note that the Height and Weight columns do not display consistently. This could be remedied by
adding a DEFINE statement for each of these columns and specifying a format^n
COMPUTE block for OBS (beginning with the COMPUTE OBS and ending with the ENDCOMP statement) specifies
how the column is populated. First, a counter, COUNT, is incremented with each pass through the data.^n The value of
COUNT is retained similar to a DATA step. The current value of the counter is then assigned to OBS.";
run ;
You might try:
run; /* end the proc report*/ Proc odstext; p "By default, PROC REPORT does not display an observation number column, which could be added with a computed variable. Also, note that the Height and Weight columns do not display consistently. This could be remedied by adding a DEFINE statement for each of these columns and specifying a"; p "COMPUTE block for OBS (beginning with the COMPUTE OBS and ending with the ENDCOMP statement) specifies how the column is populated. First, a counter, COUNT, is incremented with each pass through the data."; p "The value of COUNT is retained similar to a DATA step. The current value of the counter is then assigned to OBS."; run ;
The P basically means "start of paragraph". Each P statement can be followed by a style block.
Also you can use a data set for the source text and create somewhat nifty blocks of text. Or Proc ODSLIST may be appropriate.
BTW, it is a good idea to add a Footnote; after the Proc to clear footnotes so they don't accidentally end up after other output.
> however when I run this code normally, every thing in footnote aligned properly, but when I run in batch mode footnote is all over the place. Is there a solution for this? i
Run proc options and compare the differences between the interactive environment and the batch one.
If you don't need the Footnote behavior, i.e. placing footnote into the footer area of a document, you might experiment with Proc ODSTEXT to create long text after a table.
Instead of
Footnote2 j = l "By default, PROC REPORT does not display an observation number column, which could be added with a computed variable. Also, note that the Height and Weight columns do not display consistently. This could be remedied by
adding a DEFINE statement for each of these columns and specifying a format^n
COMPUTE block for OBS (beginning with the COMPUTE OBS and ending with the ENDCOMP statement) specifies
how the column is populated. First, a counter, COUNT, is incremented with each pass through the data.^n The value of
COUNT is retained similar to a DATA step. The current value of the counter is then assigned to OBS.";
run ;
You might try:
run; /* end the proc report*/ Proc odstext; p "By default, PROC REPORT does not display an observation number column, which could be added with a computed variable. Also, note that the Height and Weight columns do not display consistently. This could be remedied by adding a DEFINE statement for each of these columns and specifying a"; p "COMPUTE block for OBS (beginning with the COMPUTE OBS and ending with the ENDCOMP statement) specifies how the column is populated. First, a counter, COUNT, is incremented with each pass through the data."; p "The value of COUNT is retained similar to a DATA step. The current value of the counter is then assigned to OBS."; run ;
The P basically means "start of paragraph". Each P statement can be followed by a style block.
Also you can use a data set for the source text and create somewhat nifty blocks of text. Or Proc ODSLIST may be appropriate.
BTW, it is a good idea to add a Footnote; after the Proc to clear footnotes so they don't accidentally end up after other output.
It worked, Thanks
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
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.