Help using Base SAS procedures

Format certain rows like headers

Occasional Contributor
Posts: 7

Format certain rows like headers

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!

Daily Sample for web.png
Super User
Posts: 9,676

Re: Format certain rows like headers

Do you mean they have the same background ?

if ..

  then call define(_row_,......)

Posts: 8,743

Re: Format certain rows like headers


  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:

compute style_ind;

  if style_ind='H' then

     call define(_row_,'style','style=Header');


  Otherwise, there are ways in PROC REPORT to generate multiple summary lines.

See this paper, 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 ' ';
  compute after;
    country = 'Total';
ods html close;

Occasional Contributor
Posts: 7

Re: Format certain rows like headers

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:

compute User1;

if User1 in ('Daily Totals','Weekly Totals','Life-to-Date') then

call define(_ROW_,'STYLE','STYLE=header');


This changes the last 3 rows to have the same formatting as the header.  Thanks again for the help!

Ask a Question
Discussion stats
  • 3 replies
  • 3 in conversation