Hi all ods experts.
I hope I'm writing to the right group with my question.
I'm somewhat new to SAS and I have stumbled upon an issue with the combination of ODS RFT and PROC REPORT using a BY statement that google cannot solve for me:
I send the result of a PROC REPORT to word using ODS RTF. I have customized is so far, that I have suppressed the default titles the BY statements induces (OPTIONS NOBYLINE) and also the second and third node which PROC REPORT send to the TOC, but I cannot get around the subtitles/nodes the BY statement produce in the TOC. After no success for quite a while and somewhat desperate I have even tried to remove them manually in word (2016). I changed the number of 'heading levels' in a customization of the TOC, but it seems the titles are not defined as "headings" (homemade word-lingo).
Soo - does anyone know how I can avoid these extra nodes in the TOC?
I have made a reproducible example below.
data myData;
input @01 id 6.
@08 xxx 10.
@18 part $1.
@20 dummy 1.;
format id 6.
xxx 10.
part $1.
dummy 1.;
datalines;
1247 459854 1 1
1078 115487 1 1
1005 159867 2 1
1024 256897 2 1
;
options nobyline nodate nonumber orientation = landscape papersize = A4
topmargin = 1.0in bottommargin = 1.0in leftmargin = 1.0in rightmargin = 1.0in;
ods rtf file = "C:\Users\dkkds\test\test.rtf"
keepn
contents
toc_data
bodytitle
style = sapphire
startpage=yes;
%let title = %str(my header);
title font=Arial height=14pt bold "&title";
footnote font=Arial height=10pt bold "C:\Users\dkkds\test\test.sas";
footnote2 j=r height = 10pt;
ods proclabel="&title" noproctitle;* critical for meaningful toc entries;
proc report
data = myData
split = "*"
nowd
style(report) = {cellpadding = 2pt }
style(header) = {font_size = 9pt}
style(column) = {font_size = 8pt}
contents = ""; *delete second level in the table of contents;
columns dummy id xxx ;
by part;
define dummy / order noprint;
define id /'Id' order style(column) = {width = 0.40 in} center;
define xxx /'measured endpoint' style(column) = {width = 1.50 in} center;
break before dummy / contents="" page; * sletter node / niveau 3 (Table som default) i TOC (RTF);
title1 height = 13pt bold font = Arial justify = left "&title.";
title2 height = 11pt bold font = Arial justify = left " (#byval1/2)";
run;
ods rtf close;
Best regards
Kira
It would help to show the code for your ODS destination and the actual report code. Some suggestions might conflict with your current approach. Also it might help to provide some example data, just a few records to show values from two by groups so code can be tested. A short data step program would be the best way to provide data. Instructions here: https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-dat... will show how to turn an existing SAS data set into data step code that can be pasted into a forum code box using the {i} icon or attached as text to show exactly what you have and that we can test code against.
HI, so to clarify what you want to get rid of, it would be the part=1 and part=2 lines in the TOC?
cynthia
Hi:
Thanks! That "byline" is part of the identifier for the output object. It is not controlled by contents= and is not impacted by options nobyline. What is getting sent to RTF are 2 output objects, one for each by line and, even if you have turned off part=1 and part=2 in the RTF file, internally, ODS has to identify the object as it goes to the destination.
You can restructure the TOC with PROC DOCUMENT and ODS DOCUMENT, if it's worth the overhead. Basically, you create the output objects 1 time in a document store. Then you have the objects with their part=1 and part=2 structure. Next, you make a new document store in which the objects are copied in such a way that you only copy the table and not the "node" or folder that got sent with each object.
Using your same test data and your same PROC REPORT code, the new stuff in this program is the ODS DOCUMENT "sandwich" to send the original structure to the document store, and then the PROC DOCUMENT to do the rearranging. Then the PROC DOCUMENT to RTF to do the replay.
The internal names of the output objects look a bit funky, you just have to roll with it. PROC DOCUMENT with the LIST statement will let you see what the internal names are. You only have 2 by groups, so there are 2 copy statements, if you had more by groups, you would need more COPY statements. I prefer to make the top folder or top node
Here's the general idea and output.
And, here are some papers:
https://support.sas.com/resources/papers/sgf09/318-2009.pdf
https://www.mwsug.org/proceedings/2015/RF/MWSUG-2015-RF-11.pdf
http://www.lexjansen.com/nesug/nesug08/np/np08.pdf
cynthia
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
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.