BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
tarunah
Calcite | Level 5

I would like to remove the average row when the mean for the total column is 0. For e.g. in the output below I want to delete the average row for Name = X since the average of Total column is 0.

 

Averages are calcuated as follows -

define a / analysis mean 'a' style={tagattr='format:###,###,##0.00'};
define b / analysis mean 'b' style={tagattr='format:###,###,##0.00'};
define c / analysis mean 'c' style={tagattr='format:###,###,##0.00'};
define total / analysis mean 'total' style={tagattr='format:###,###,##0.00'};

 

break after Name;

 

DateNameabcTotal
02/11/2017X0.000.000.000.00
02/18/2017X0.000.000.000.00
 Average0.000.000.000.00
02/11/2017Y45.000.007.5045.00
02/18/2017Y45.000.004.0045.00
02/25/2017Y43.000.005.0043.00
03/04/2017Y21.000.002.0021.00
 Average38.500.004.6338.50

 

Thanks for your help.

1 ACCEPTED SOLUTION

Accepted Solutions
RW9
Diamond | Level 26 RW9
Diamond | Level 26

Whilst you may be able to do this in compute blocks, I tend to find it easier to get a dataset looking right before reporting it out. Easier to QC, and work with.  So two steps:

proc report data=... out=want;
...
run;

data want;
  set want;
  if name="Average" and total=0 then delete;
run;

/* Now we actually report it out */
proc report data=want;
...
run;

Of ourse you don't need to use proc report, you could use other procedures.

View solution in original post

1 REPLY 1
RW9
Diamond | Level 26 RW9
Diamond | Level 26

Whilst you may be able to do this in compute blocks, I tend to find it easier to get a dataset looking right before reporting it out. Easier to QC, and work with.  So two steps:

proc report data=... out=want;
...
run;

data want;
  set want;
  if name="Average" and total=0 then delete;
run;

/* Now we actually report it out */
proc report data=want;
...
run;

Of ourse you don't need to use proc report, you could use other procedures.

SAS INNOVATE 2024

Innovate_SAS_Blue.png

Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.

If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website. 

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.

Get the $99 certification deal.jpg

 

 

Back in the Classroom!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 1 reply
  • 1824 views
  • 0 likes
  • 2 in conversation