BookmarkSubscribeRSS Feed
Katie_Lane
Calcite | Level 5

Trying out ODS Word. I realize it is pre-production.  Perhaps I am just writing something wrong.  I have 3 different proc prints/ODSTEXT statements each with a unique title.  However, I only see the first title showing in the created Word file although in the listing i do see the correct titles.  I did turn startpage off to all be on 1 page and when i toggle that back to yes, I do see all 3 titles.  Please help me understand why setting startpage=no does not allow me to have separate titles.

 

ods word file='h:\testing.docx' sasdate options(body_title='yes' toc_data='on') nogtitle startpage=no;

 

proc print data=fun; title 'Does it print'; run;

proc print data=fun; title '2nd title'; run;

proc print data=fun; title '3rd title'; run;

 

ods word close;

 

6 REPLIES 6
ballardw
Super User

Did you try  the option as "bodytitle" instead of "body_title"?

 

If you don't have any graphic output I might suggest removing the NOGTITLE as well.

Katie_Lane
Calcite | Level 5
I have toggled the nogtitle and gtitle - no change. Bodytitle gives an error. Bodytitle works in ODS RTF but for ODS WORD it is now nested inside options and spelled differently.
Cynthia_sas
Diamond | Level 26

Hi:

  Except for misspelling 3rd as 3nd, I can get close to what you want with ODS TEXT:

Cynthia_sas_0-1605212505038.png

 

 

Or using PROC REPORT and a COMPUTE block:

Cynthia_sas_1-1605212818800.png

 

Hope this helps,

Cynthia

 

Katie_Lane
Calcite | Level 5
i don't get it. This is mine after I cut/paste from the Word file. As you can see, I only have 1 title, the 1st.

Does it print

Obs
a
1 1
2 2
3 3


Obs
a
1 1
2 2
3 3


Obs
a
1 1
2 2
3 3
Cynthia_sas
Diamond | Level 26

Hi:

 I can't run your code since I don't have your data. However, when I run the code that I posted, I get the results shown in my screen shots. Here's my code using SASHELP data so anyone can run it.

 

** Example 1;
ods word file='c:\temp\testings.docx' sasdate nogtitle startpage=no
    options(bodytitle='yes' toc_data='on');

proc print data=sashelp.class(obs=3);
  title 'Does it print at top of page';
run;

ods text="2nd title (pseudo title with ODS TEXT)";
proc print data=sashelp.shoes(obs=2); run;

ods text="3rd title (pseudo title with ODS TEXT)";
proc print data=sashelp.classfit(obs=3); run;

ods word close;

** Example 2;
ods word file='c:\temp\report_example.docx' sasdate nogtitle startpage=no
    options(bodytitle='yes' toc_data='on');

proc report data=sashelp.class(obs=3);
  title 'Does it print at top of page';
run;

proc report data=sashelp.shoes(obs=2);
compute before _page_ / style=SystemTitle;
  line "2nd title (pseudo title with PROC REPORT)";
endcomp;
run;

options nolabel;
proc report data=sashelp.classfit(obs=3);
compute before _page_ / style=SystemTitle;
  line "3rd title (pseudo title with PROC REPORT)";
endcomp;
run;

ods word close;

  If my code doesn't work for you as shown in my screen shots using SASHELP data, then my suggestion is that you open a track with Tech Support. Just because BODYTITLE with ODS RTF works as you want does not mean that the option will work the same way in ODS WORD:

Cynthia_sas_0-1605280786189.png

 Perhaps this is something (making BODYTITLE work the same in ODS WORD) is something that is on the drawing board. Perhaps this is something that they can't do in ODS WORD. If you want the ODS RTF behavior with BODYTITLE, then use ODS RTF. If you want to use ODS WORD, then there are 2 workarounds with ODS WORD - -either ODS TEXT or using PROC REPORT with a COMPUTE block. For more in-depth help on BODYTITLE and ODS WORD, if neither of these options will work for you and if using ODS RTF doesn't work, then you'll need to work with Tech Support on this question.

 

Cynthia

Katie_Lane
Calcite | Level 5

Thanks Cynthia. I will do that.

 

Catch up on SAS Innovate 2026

Dive into keynotes, announcements and breakthroughs on demand.

Explore 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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 6 replies
  • 3349 views
  • 1 like
  • 3 in conversation