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
SAS Super FREQ

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

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!

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.

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