Pre-calculated sums, display in proc report

Reply
Frequent Contributor
Posts: 133

Pre-calculated sums, display in proc report


Hi SAS Experts,
I have pre-calculated sums in my source data table:

Example:

Group--Substance--Positives
A______Ivy________34
A______Box________3
Asum______________17
B______Ivy________11
B______Box________25
Bsum______________40

The custom sums are not logical "sums" top-down
but present a "different" way of summing up.
So I cant use a GROUP and BREAK in my PROC REPORT
but must display those custom sums as if they
indeed where just caused by GROUP and BREAK.

There is the problem of order, how does SAS now
that Asum should come after all the A's and second
how to display my pre-calculated number as a "sum" i.e. GROUP / BREAK.

Can someone point me in the right direction?

@RW9, this is a requirement by the end-user.
I have not chosen to create those weird totals/sums
that do not really represent totals.

Super User
Super User
Posts: 7,710

Re: Pre-calculated sums, display in proc report

Just do it in the datastep.  If you want subgroups:

data inter;

  set want;

  if group="Asum" then do;

    line="----------------"; output;

    line=strip(group)||" - "||strip(put(positives,best.));

    line="--------....

run;

 

So set your dataset up eaxctly as you want the output to look, don't try to do illogical things through logical processes.  Alternatively, add another variable to group things?

Super User
Posts: 19,064

Re: Pre-calculated sums, display in proc report

Create a variable that maps to your grouping and use that.
Super User
Posts: 11,115

Re: Pre-calculated sums, display in proc report

If your group and substance values are separate variables you should be okay just calling them grouping variables though you may needt to specify that missing values of substance are okay. And if the values are are precalculated then look at using a listing style report, no summary statistics (sum ) needed.

 

Ask a Question
Discussion stats
  • 3 replies
  • 231 views
  • 0 likes
  • 4 in conversation