05-10-2013 03:37 PM
Hi again folks,
As a newbie, I coded a report from scratch to practice using proc report - here's that code:
proc report data=WORK.DISP_FMT_ALL nofs;
columns COUNT_of_ALERT_DISPOSITION_ID SUM_of_HR SUM_of_SU SUM_of_CR SUM_of_FN SUM_of_CL SavedAmount LossAmount;
define COUNT_of_ALERT_DISPOSITION_ID / display style(header)=[cellwidth=60];
define SUM_of_HR / display style(header)=[cellwidth=50] "HR";
define SUM_of_SU / display style(header)=[cellwidth=50] "SU";
define SUM_of_CR / display style(header)=[cellwidth=50] "CR";
define SUM_of_FN / display style(header)=[cellwidth=50] "FN";
define SUM_of_CL / display style(header)=[cellwidth=50] "CL";
define SavedAmount / display style(column)=[cellwidth=100] FORMAT=dollfmt. "Saved";
define LossAmount / display style(column)=[cellwidth=100] FORMAT=dollfmt. "Loss";
Question: How can I give the last 3 rows the same formatting as the header row? It will help as a visual cue between the detail and total rows.
Thanks in advance!
05-11-2013 10:19 AM
KSharp is correct, you could use CALL DEFINE. On the other hand, if you allowed PROC REPORT to do the summarizing, then you could simply put
proc report data=orig_data nowd
...more code ...
and that would cause all the summary lines to be formatted as a header. (see example at the end of the post for this technique)
But since you "pre-summarized" the data, you are the only person who knows that the last 3 rows are meant to show as summary rows. If you are going to continue to "pre-summarize" the data, then you will need to identify the rows for how you want them styled. I would suggest creating a variable called STYLE_IND and make it D when you want "data" style and H when you want "header" style, then you could have code like this:
if style_ind='H' then
Otherwise, there are ways in PROC REPORT to generate multiple summary lines.
See this paper, http://support.sas.com/rnd/papers/sgf07/sgf2007-report.pdf page 7 and 8. She doesn't show the style change in this paper, but the technique below would still work. Here's an example of doing summaries with a Header style automatically. SASHELP.PRDSALE has 1440 observations, but the GROUP usage allows PROC REPORT to collapse and summarize the individual observations in rows at the specified break points. Note the value for COUNT on the final summary line on the report.
ods html file='c:\temp\autosum.html';
proc report data=sashelp.prdsale nowd
title 'Automatic Style for Summary';
column country division product n actual predict;
define country / group;
define division / group;
define product / group;
define n / 'Count';
define actual / sum;
define predict / sum;
break after division / summarize;
break after country / summarize;
rbreak after / summarize;
compute after country;
line ' ';
country = 'Total';
ods html close;
05-14-2013 10:05 AM
Thanks Cynthia & Ksharp - I did end up going the call define route. In this case, I used a value-check for a column I added to change the formatting based on whether the row is a summary row or not:
if User1 in ('Daily Totals','Weekly Totals','Life-to-Date') then
This changes the last 3 rows to have the same formatting as the header. Thanks again for the help!