I have been creating a macro that creates some ODS output along with a Table of Contents.
My macro has a switch that allows users to select RTF, PDF or Word output (there are reasons for having the option of RTF and DOCX separately).
The macro has an option to insert custom text for the TOC title line.
If i'm using ODS RTF I can manipulate the template style I am using and change the title within ContentTitle:
style ContentTitle from ContentTitle /
pretext = ""
posttext="Line1(*ESC*){newline}Line2"
color = dark blue;
Notice I want multiple lines in the title, so i use the ODS escape command {newline}.
However, when I try and do the same for ODS WORD, no formatting is honored
I have tried the following (creating the string as a macro variable to insert into the template):
data _null;
*call symputx('testtitle', catx('0A'x, "Line1", "Line2"));
call symputx('testtitle', "Line1(*ESC*){newline}Line2");
*call symputx('testtitle', "Line1\nLine2");
run;
proc template;
define style styles.test_docx;
parent=styles.word;
style ContentTitle from ContentTitle /
content = "&testtitle."
/*protectspecialcharacters=on*/
/*asis=on*/
/*contenttype="text/plain"*/
;
end;
run;
ODS Escape sequences did not work, neither did ASCII like break characters or the simple "\n" (which weirdly printed out as "¥n"). I tried some other options I dug out of the log, like "protectspecialchars", "asis", etc but nothing seems to want to make a line break in an ODS WORD TOC.
Does anyone have a solution before I contact the Technical guys?
Full testing program attached.
... View more