ods rtf file="D:test.rtf";
ods escapechar='^';
title 'table: using ods in proc report';
proc report data=sashelp.class;
column sex name ("BMI Parameters" height weight);
define sex/order;
define name/display 'student name' style(column)={asis=on cellwidth=1.5 in just=l} flow;
define height/analysis format=5.1 style(column)={asis=on cellwidth=1.5 in just=l} flow;
define weight/analysis format=6.2 style(column)={asis=on cellwidth=1.5 in just=l} flow;
compute after _page_;
line "footnote: xxxxx";
line "^S={just=left}...path\xxx\xxx.sas" "^S={just=right}[&sysdate9.]"; /*1.doesn't work*/
line '^R"\ql"' "...path\xxx\xxx.sas" '^R"\qr"' " [&sysdate9.]"; /*2.doesn't work*/
endcomp;
run;
title;
ods rtf close;
Here is the sample code
The final result I want is in the picture.
Hi:
It would be much better to use an actual footnote for what you want to do and to abandon the idea of using the LINE statement in RTF for this. In RTF, when the RTF file is opened, the cell from the COMPUTE block is treated as having 1 justification in the whole cell, so it is hard to change ODS to send any different justification. Consider this with a table that I just TYPE manually into Word:
I can left justify the whole line of text at the bottom, I can center what's in the merged cell or I can right justify the whole string, but with just typing I can't force the date to the right. I could insert tab characters or spaces, but depending on the length of the text on the left, the number of spaces or tabs would vary too much and would be hard to calculate.
On the other hand, the TITLE and FOOTNOTE statements are designed to have pieces of the string justified differently.
Some other comments on your PROC REPORT code:
1) FLOW is a LISTING-only option that is ignored by ODS -- so you may as well take that out of your code.
2) Not sure why you're using ASIS=ON, there's no special formatting you are using for which you would need ASIS=ON.
3) When you try RTF control strings (^R), you usually also need to specify PROTECTSPECIALCHARS=OFF.
4) You might consider the use of SPANROWS on the PROC REPORT statement to remove the interior table lines in the SEX column.
Here's some alternate code that shows the difference between the text in the COMPUTE block using NBSPACE to insert non-breaking spaces into the text in the COMPUTE block and the way that FOOTNOTE looks. The output was created using both ODS RTF and ODS TAGSETS.RTF because their way of placing FOOTNOTE text differs, as shown below:
Code:
Output:
Hope this helps. I think if you want the footnote immediately under the table, then using TAGSETS.RTF will give you that look and you can accomplish the differing justifications just using j=l and j=r.
Cynthia
Thanks for your answer, Cynthia.😁
This is a sample code to test my final result, I cut out a small portion . I know that it works in the title and footnote using j=l and j=r.
My questions:
1.how to align left xxx1 and align right xxx2 in a same line , not in a title and footnote?
2.don't use ^{nbspace xx} to align left xxx1 and align right xxx2, since different tables have different length for the text "...path\xxx\xxx.sas ^{nbspace xx??}[&sysdate9.]";
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.