The SAS Output Delivery System and reporting techniques

Styles for last line in proc report

Reply
Frequent Contributor
Posts: 102

Styles for last line in proc report

I'd like to make the last line in which SAS automatically sums the statistics for me gray and bold? Is it also possible to add "Grand Total" to the row?

Code:

proc report data=have nowd split='/';

    title 'Building_id and Building_name';

   by building_id;

  columns Type Subtype Region Count Expected count_ontime late pct_within pct_not_within;

  define Type/display  " Type";

  define subtype /display  "subtype";

  define  Region/display  "Region";

  define Count/ display "Count";

  define Expected/  display 'Expected';

  define count_ontime/display '# Ontime';

  define late/display  '# late';

  define Pct_within/display  '% ontime' format=PERCENT7.0;

  define Pct_not_within/display  '% late' format=PERCENT7.0;

run;

Frequent Contributor
Posts: 113

Re: Styles for last line in proc report

Hi,

Please try ..

ods html body=’external-HTML-file’;

ods pdf file=’external-PDF-file’;

ods rtf file=’external-RTF-file’;

proc report data= DSN nowd headline headskip;

style(report)=[cellspacing=5 borderwidth=10 bordercolor=blue] ;

style(header)=[color=yellow fontstyle=italic fontsize=6];

style(column)=[color=moderate brown fontfamily=helvetica fontsize=4];

style(lines)=[color=white backgroundcolor=black fontstyle=italic fontweight=bold fontsize=5];

style(summary)=[color=cx3e3d73 backgroundcolor=cxaeadd9 fontfamily=helvetica fontsize=3 textalign=r];

.

Column ......;

define .....;

run;

ods html close;

ods pdf close;

ods rtf close;

Kindly change in style options as per your requirement....

Regards

Uma Shanker Saini

SAS Super FREQ
Posts: 8,646

Re: Styles for last line in proc report

Hi:

  Many of these questions have been asked already in previous forum postings. For example, you can use a STYLE override to change the summary line. But in order for it to work, you need to have a BREAK or an RBREAK statement in the code. I don't see that. How are you getting a summary line without a BREAK or RBREAK statement?

  Also, to change the value at the BREAK to something like Grand Total, you would need a COMPUTE block. Again, in order to do this, you can only use COMPUTE AFTER brkvar or COMPUTE AFTER. I only see that you are using DISPLAY as your usage in PROC REPORT, so you can't "hook" a COMPUTE block onto DISPLAY items in order to rename something at the summary, since there won't be a summary without a BREAK or RBREAK statement. See the attached program. Output #1 will not have any summary line to get the gray  background color because there is no BREAK or RBREAK statement. But, output #2 will have a gray background to the summary line because of the RBREAK statement and the usage of SUM for the numeric variables.

  Are you sure that this code is generating a summary line? When I do something similar with SASHELP.SHOES and a BY statement, I do not get a SUMMARY line. Also, you do not say what your destination of interest is. If you are getting LISTING output, then you could not change the summary line, but if you were using HTML, RTF or PDF, etc, then you could change the summary line.

  Here's a paper that may serve to get you started on STYLE= overrides (http://support.sas.com/resources/papers/proceedings13/366-2013.pdf), but for more info on PROC REPORT, you may want to look at the documentation topic entitled, "How PROC REPORT Builds a Report".

cynthia

** make a small subset;

proc sort data=sashelp.shoes out=shoes;

where region in ('Asia', 'Africa') and

      product in ('Boot', 'Sandal');

by region;

run;

   

ods html file='c:\temp\tryshoes.html';

 

proc report data=shoes nowd

  style(summary)={background=cxcccccc font_weight=bold};

title '1) All variables as DISPLAY no BREAK or RBREAK';

title2 'nothing for STYLE(SUMMARY) to impact';

by region;

column product sales inventory returns;

define product / display;

define sales / display;

define inventory/ display;

define returns/ display;

run;

   

proc report data=shoes nowd

  style(summary)={background=cxcccccc font_weight=bold};

title '2) Char variables as DISPLAY only RBREAK';

title2 'numeric vars have to be usage of sum';

by region;

column product sales inventory returns;

define product / display;

define sales / sum;

define inventory/ sum;

define returns/ sum;

rbreak after / summarize;

compute after;

   product = 'Grand Total';

endcomp;

run;

  

ods html close;

Frequent Contributor
Posts: 113

Re: Styles for last line in proc report

Hi,

Sorry i missed "Grand Total"

Thanks Synthia..

Post a Question
Discussion Stats
  • 3 replies
  • 277 views
  • 1 like
  • 3 in conversation