BookmarkSubscribeRSS Feed
dharm
Calcite | Level 5

Hi,

I am using BY statement in report procedure to create diff report as per BY variable value. i am also creating TOC for report by writing content and toc_data in ODS statement.

Creating diff report as per BY value is fine. but in TOC i can see the variable which i used for BY variable is showing by default and it looks weird in TOC.

as like suppose my BY Variable is PRODUCT and contain four raw A,B,C,D. so i can see in TOC there are Product = A, product = b etc....

can anyone help me to remove this default line of BY Variable from TOC in RTF file.

thank you...

8 REPLIES 8
dharm
Calcite | Level 5

Thanks RW9 for the reply.

but the doc which u given is showing to remove all the content of the report if i am not wrong (Delete / contents - in the proc document).

i have tried by my own way and i can replace the default byval coming in TOC by using setlabel statement in the proc doc. but as i am working with macro and process is iterating many times , its not working with big task.

may b you dont understand my concern . so please find below code as example.

********************************************************************************************************

data a;
input name $ sal num;
cards;
abc 123 1
abc 234 1
abc 234 1
mno 122 2
mno 234 2
xyz 123 3
xyz 123 3
;
run;

ods proclabel = " ";
ods rtf file="outpath\new.rtf" contents=on toc_data;

proc report data =a nowd contents="salary of #byval(name)";
by name;
column name sal num;
define name / order Display;
define sal / Display;
define num / order order=data noprint;
break before num / page contents=' ';

run;

ods rtf close;

******************************************************

please run above code and you will come to know that by default BYVAL is coming in TOC which looks weird.  i am looking for the option which can remove that BYVAL from TOC..

thanks..

RW9
Diamond | Level 26 RW9
Diamond | Level 26

Yes, I am familiar with the TOC and byval's.  The only method however of modifying TOC information in SAS ODS at least to my knowledge is by using proc document.  The link I posted was an example, meant to guide you.  Its irrelevant how the ODS output is created, just make sure to open the document object before all outputs.  The document object can be read in an programmatically modified from there.  It is however a lot of work.  Me personally I would change my approach, and instead of using byvals, generate the code yourself, hence generating proc labels as well.

Cynthia_sas
SAS Super FREQ

HI:

  Before PROC DOCUMENT, there was the "macro" method of impacting the table of contents (essentially using a macro program to invoke the procedure for every BY group). For example, see the code in the screen shot below. My example shows how to use PROCLABEL and CONTENTS= to change the TOC without needing to use PROC DOCUMENT -- without BY groups. I didn't do my code in a macro program or use BY group processing. The thing is that BY group processing would not work for this because ODS PROCLABEL and CONTENTS= do not happen at the BY group level. So I find this older approach works better if all I need to do is control the name in the TOC for every group. This Tech Support note explains how to get PROC REPORT to suppress the lowest level "Table 1" node. 31278 - Table 1 node generated by PROC REPORT

cynthia


example_toc_rtf_no_proc_doc.png
dharm
Calcite | Level 5

Thanks cynthia and RW9 for your help...

cynthiya : - if you see in the example in my previous reply to RW9, i had given one example to show him that what i am looking for. actually in that example i have suppresed third level of TOC (e.g "Table1") from the report . and i can remove second level also by using contents= option in report statement.

but my concern is, how can i remove those lines of TOC which has been generated by BY Statement. i am not seeing any helpful doc or info from sas or from net to resolve this issue.

is there no alternative way to remove BYVAL from TOC which generate by default when use BY statement?

thankss...

Cynthia_sas
SAS Super FREQ

Hi:

  If you want to stick with the BY approach, then you might consider relabeling NAME to be the "Salary For" and suppress the CONTENTS= on the PROC REPORT statement. See screen shot. Otherwise, ODS DOCUMENT/PROC DOCUMENT will be your only approach. Even with OPTIONS NOBYLINE, you don't impact the BYLINE in the TOC. So you will have to modify those using ODS DOCUMENT.

  Or, as I showed in my program, instead of using BY group processing use a separate REPORT step for each BY variable value. I did not, but you could write a SAS Macro program to generate a separate report for every BY variable value (in this instance, you would get rid of the BY statement) and for your example, would run your PROC REPORT step 1 time for each BY variable.

  If there is any OTHER alternative to removing the BYVAL from the TOC, that would be something to check with Tech Support.

cynthia


alternative_with_by_toc.png
dharm
Calcite | Level 5

thanks cynthiya...

and yes, that is the final option i have..like i must have to move ahead with seperate by group and needs to create seperate report procedure for all.. but i am shocked..cause as far as i know when there is anyhting added in our output bydefault by SAS,  then there are a alternative options to remove it...as like suppose i am creating Report by using PROC REPORT , then "The Report Procedure" line is the default in TOC by SAS. but we can suppress it by using NOPROCTITLE option. so same should be for BYVAL also..but unfortunately we dont have a direct option through which we can remove it...

BDW thanks cynthiya and RW9 for the time...will defenately post the solution in the same discussion in the future if i will have any...so we can make a use of  BYVAL to create a report with better TOC...

thanks...

RW9
Diamond | Level 26 RW9
Diamond | Level 26

Best of luck, I completely agree with you, generate documents from within SAS does need to be updated, particularly TOC/bookmarks.  In most instance I have seen, people just generate one output per file, then outside of SAS combine, using VB scripting and postscript files or PDF maker etc.

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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
  • 8 replies
  • 2074 views
  • 0 likes
  • 3 in conversation