BookmarkSubscribeRSS Feed
blueskyxyz
Lapis Lazuli | Level 10
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 codeCapture.PNG 

The final result I want is in the picture.

3 REPLIES 3
Cynthia_sas
SAS Super FREQ

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:

Cynthia_sas_0-1606579400528.png

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:

Cynthia_sas_1-1606582261450.png

 

Output:

Cynthia_sas_2-1606582302431.png

 

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

 

blueskyxyz
Lapis Lazuli | Level 10

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.]";

 

 

 

Cynthia_sas
SAS Super FREQ
Hi:
As I explained in my original posting, in regard to #1 -- in a merged cell in Word, without using any SAS at all, but just using Word, as shown in my very first screen shot -- in Word, the text in a merged cell can only have 1 justification. What you write with a LINE statement becomes a merged cell, so your answer to #1 is that you must insert spaces or tabs or (NBSPACE}, which you say in #2, that you don't want to do.
So the answer might be to switch to TAGSETS.RTF and use a FOOTNOTE statement, or to redesign what you write with the LINE statement so that the date appears first and then the string you want:
20Nov2020: /path/xxx/xxx/xxx.sas

At any rate, I do not know a way to do what you want without using {NBSPACE} or tabs.

Cynthia

SAS Innovate 2025: Call for Content

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!

Submit your idea!

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
  • 3 replies
  • 1647 views
  • 1 like
  • 2 in conversation