BookmarkSubscribeRSS Feed
milts
Pyrite | Level 9

Hi,

I have this sample dataset. What I want to happen on my proc report is that I on the row for the totals,  I only want a value displayed for the column two and column one should not have a summary value. Is this possible? Please see script below and current and desired results. Thanks!

data test;

    input nm $ one two;

    datalines;

one 1 10

two 2 20

three 3 30

;

proc report data=test;

    column nm one two ;

    define nm / display;

    define one / analysis sum;

    define two / analysis sum;

    rbreak after / summarize;

    compute after;

        if _break_ = '_RBREAK_' then do;

            nm = 'Total';

        end;

    endcomp;

run;

quit;

Current Output

nmonetwo
one110
two220
three330
total660

Desired Output

nmonetwo
one110
two220
three330
total
60
2 REPLIES 2
Cynthia_sas
Diamond | Level 26

Hi:

  If variable ONE has a usage of SUM ANALYSIS, it will be summarized during break processing. If variable ONE has a usage of DISPLAY, it will NOT be summarized at break processing. This is a simple fix and understanding the difference between DISPLAY and SUM is fundamental to how PROC REPORT decides which columns get summarized or not.

cynthia

Ksharp
Super User

Sure. Of course.

data test;
    input nm $ one two;
    datalines;
one 1 10
two 2 20
three 3 30
;
run;

 
option missing='';
proc report data=test  nowd;
    column nm one two ;
    define nm / display;
    define one / analysis sum;
    define two / analysis sum;
    rbreak after / summarize;
    compute after;
        if _break_ = '_RBREAK_' then do;
            nm = 'Total'; call missing(one.sum);
        end;
    endcomp;
run;

Ksharp

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 1091 views
  • 0 likes
  • 3 in conversation