BookmarkSubscribeRSS Feed
Tarun
Calcite | Level 5

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";

run;

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
3 REPLIES 3
Ksharp
Super User

Do you mean they have the same background ?

if ..

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

Cynthia_sas
SAS Super FREQ

Hi:

  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

       style(summary)=Header;

...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');

endcomp;

  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.

cynthia

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

proc report data=sashelp.prdsale nowd
     style(summary)=Header;
  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 ' ';
  endcomp;
  compute after;
    country = 'Total';
  endcomp;
run;
 
ods html close;

Tarun
Calcite | Level 5

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');

endcomp;

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

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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
  • 3 replies
  • 847 views
  • 2 likes
  • 3 in conversation