Hello,
When running the following program in the past (under SAS 9.1.3), the two ODS TEXT statements would create a table in the RTF document with two rows and the width of the table would be "full page width" (minus the left and right margins defined in the style. However, when I run the program in SAS 9.3, I notice that I still get a two-row table but the width is determined by the largest text content of each cell. This means that the logo that I put in the first row gets "cut" depending on the width of the second row.
Here is sample code to reproduce the issue:
ODS ESCAPECHAR="^";
ODS RTF STYLE=JOURNAL BODYTITLE FILE="TEST.RTF";
ODS RTF STARTPAGE=NEVER;
ODS RTF TEXT="^S={preimage='C:\SAS_TPTK_logo.jpg'} ";
ODS RTF TEXT="Second line";
PROC PRINT DATA=SASHELP.CLASS;
RUN;
ODS RTF CLOSE;
I've also attached two image files showing the previous and current behaviors. Is there any way I can specify the width of the table that gets created by the ODS RTF TEXT statement?
Thank you,
Daniel
I just received a reply from TS and they suggested the following two options to fix the issue:
1) Use outputwidth=100% option in the ODS TEXT statement;
2) Modify the style being used so that the the outputwidth of the ODS TEXT element (usertext in the style definition) is 100%.
1) Would be as follows:
ODS ESCAPECHAR="^";
ODS RTF STYLE=JOURNAL BODYTITLE FILE="TEST.RTF";
ODS RTF STARTPAGE=NEVER;
ODS RTF TEXT="^S={outputwidth=100% preimage='C:\SAS_TPTK_logo.jpg'} ";
ODS RTF TEXT="Second line";
PROC PRINT DATA=SASHELP.CLASS;
RUN;
ODS RTF CLOSE;
2) Would be as follows:
ods path work.template(update) sashelp.tmplmst;
proc template;
define style styles.myjournal;
parent=styles.journal;
style usertext from usertext / just=c outputwidth=100%;
end;
run;
Thank you very much to Bari from TS for the quick reply and the two solutions to this problem!
Hi, I no longer have SAS 9.1.3 to test with. And, at any rate, differences between 1 version of SAS and another version of SAS is a signal of something that you should open a track with Tech Support. They can test in the older version and the current version in order to open a defect with the developers, if necessary.
cynthia
Thank you Cynthia, I'll contact TS. In the meantime I've found a workaround of sorts by replacing both ODS RTF TEXT statements with a PROC REPORT based on a dataset that has two observations, each equal to the contents of each ODS RTF TEXT= line and using STYLE=[FRAME=VOID RULES=NONE] to remove the borders and STYLE=[CELLWIDTH=xxIN] in the DEFINE statement to control the width.
The leftmargin and rightmargin options with RTF TEXT might also work by forcing the length of the lines.
I just received a reply from TS and they suggested the following two options to fix the issue:
1) Use outputwidth=100% option in the ODS TEXT statement;
2) Modify the style being used so that the the outputwidth of the ODS TEXT element (usertext in the style definition) is 100%.
1) Would be as follows:
ODS ESCAPECHAR="^";
ODS RTF STYLE=JOURNAL BODYTITLE FILE="TEST.RTF";
ODS RTF STARTPAGE=NEVER;
ODS RTF TEXT="^S={outputwidth=100% preimage='C:\SAS_TPTK_logo.jpg'} ";
ODS RTF TEXT="Second line";
PROC PRINT DATA=SASHELP.CLASS;
RUN;
ODS RTF CLOSE;
2) Would be as follows:
ods path work.template(update) sashelp.tmplmst;
proc template;
define style styles.myjournal;
parent=styles.journal;
style usertext from usertext / just=c outputwidth=100%;
end;
run;
Thank you very much to Bari from TS for the quick reply and the two solutions to this problem!
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.