The SAS Output Delivery System and reporting techniques

suppress node in TOC created from Proc Report when using a by statement

Reply
New Contributor
Posts: 4

suppress node in TOC created from Proc Report when using a by statement

[ Edited ]

 

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

Super User
Posts: 11,343

Re: suppress node in TOC created from Proc Report when using a by statement

Posted in reply to KiraDynnes

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.

New Contributor
Posts: 4

Re: suppress node in TOC created from Proc Report when using a by statement

Hi,
Thank you for your reply.
I've added an example - not in the data-step way, But it should be copy-paste ready. I hope this makes my question more clear.

Br Kira
SAS Super FREQ
Posts: 8,864

Re: suppress node in TOC created from Proc Report when using a by statement

Posted in reply to KiraDynnes

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

what_change_toc.png

New Contributor
Posts: 4

Re: suppress node in TOC created from Proc Report when using a by statement

Posted in reply to Cynthia_sas
Hi Cynthia
That is exactly what I want - sorry for being unclear :-)
Kira
SAS Super FREQ
Posts: 8,864

Re: suppress node in TOC created from Proc Report when using a by statement

Posted in reply to KiraDynnes

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.

ods_document_restructure.png

 

  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

New Contributor
Posts: 4

Re: suppress node in TOC created from Proc Report when using a by statement

Posted in reply to Cynthia_sas
Wauw Cynthia! Thank you for your through answer. I guss it might not be worth the overhead. At the very end a pragmatic solution is also just to delete the nodes from the TOC. But still - thank you so much!

Br Kira
Ask a Question
Discussion stats
  • 6 replies
  • 198 views
  • 0 likes
  • 3 in conversation