BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
Chetan302
Calcite | Level 5

I have created rtf file reading 2 PNG files displayed separately in two pages using ods text statement but with same title and page number.
Need to have different title and page number for both rtf pages. 
code I am using looks like:-
%let _std_ods_type = rtf;

title 1 'page (1 of 2)';

title3 "Treatment 1";

ods rtf file = 'path/trackerfile_name.outpt_reference' style = custom startpage = never;

ods text = 'path/file_name1.png' ;

title 1 'page (2 of 2)';

title3 "Treatment 2";

ods text = 'path/file_name2.png' ;

ods rtf close;

This code is giving titles defined first in both pages.

If I pass the code in simple loop then getting titles defined at last in both pages.

 

1 ACCEPTED SOLUTION

Accepted Solutions
Bari_sas
SAS Employee

While you see the images on separate pages, the ODS RTF TEXT= statement will not force a page break / step boundary, which is what is required for the title to change. I suggest using PROC ODSTEXT instead. I have success with the following code in SAS 9.4m8. Please let me know your results.

 

 

options nodate nonumber;
ODS LISTING GPATH = "/tmp"; ods graphics on / imagename="first" imagefmt=png border=off; proc sgplot data=sashelp.class; scatter x=height y=weight; ellipse x=height y=weight; run; ods graphics on / imagename="second" imagefmt=png border=off; proc sgplot data=sashelp.cars; hbox weight / category=origin; run; ods listing close; ods escapechar="^"; %let _std_ods_type = rtf; title1 'Page ^{thispage} of ^{lastpage}'; title3 "Treatment 1"; ods rtf file = '/tmp/file.rtf' ; proc odstext; P '^S={outputwidth=100% preimage="/tmp/first.png"}'; run; title1 'Page ^{thispage} of ^{lastpage}'; title3 "Treatment 2"; proc odstext; P '^S={outputwidth=100% preimage="/tmp/second.png"}'; run; ods rtf close;

Here's a snippet of my titles from each page:

Bari_sas_0-1699908484558.png

 

 

 

View solution in original post

5 REPLIES 5
Bari_sas
SAS Employee

While you see the images on separate pages, the ODS RTF TEXT= statement will not force a page break / step boundary, which is what is required for the title to change. I suggest using PROC ODSTEXT instead. I have success with the following code in SAS 9.4m8. Please let me know your results.

 

 

options nodate nonumber;
ODS LISTING GPATH = "/tmp"; ods graphics on / imagename="first" imagefmt=png border=off; proc sgplot data=sashelp.class; scatter x=height y=weight; ellipse x=height y=weight; run; ods graphics on / imagename="second" imagefmt=png border=off; proc sgplot data=sashelp.cars; hbox weight / category=origin; run; ods listing close; ods escapechar="^"; %let _std_ods_type = rtf; title1 'Page ^{thispage} of ^{lastpage}'; title3 "Treatment 1"; ods rtf file = '/tmp/file.rtf' ; proc odstext; P '^S={outputwidth=100% preimage="/tmp/first.png"}'; run; title1 'Page ^{thispage} of ^{lastpage}'; title3 "Treatment 2"; proc odstext; P '^S={outputwidth=100% preimage="/tmp/second.png"}'; run; ods rtf close;

Here's a snippet of my titles from each page:

Bari_sas_0-1699908484558.png

 

 

 

Chetan302
Calcite | Level 5
Thank you so much for your prompt reply. This work around works for me
ballardw
Super User

What happens if you remove the STARTPAGE=NEVER from the ODS Rtf statement?

Chetan302
Calcite | Level 5
Thank you so much for your valuable inputs. I have tried by removing it and by changing STARTPAGE options but no luck.
Ksharp
Super User
options nodate nonumber;
ods escapechar="^";
title1 'Page ^{thispage} of ^{lastpage}';
title3 "Treatment 1";
ods rtf file = 'c:\temp\a\file.rtf'  nogtitle dpi=300 ;

ods graphics on / border=off outputfmt=png;
proc sgplot data=sashelp.class;
scatter x=height y=weight;
ellipse x=height y=weight;
run;

/*title1 'Page ^{thispage} of ^{lastpage}';*/
title3 "Treatment 2";
ods graphics on / border=off  outputfmt=png;
proc sgplot data=sashelp.cars;
hbox weight / category=origin;
run;
ods rtf close;

Ksharp_0-1700112572139.png

 

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

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
  • 5 replies
  • 779 views
  • 5 likes
  • 4 in conversation