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;
Date | Name | a | b | c | Total |
02/11/2017 | X | 0.00 | 0.00 | 0.00 | 0.00 |
02/18/2017 | X | 0.00 | 0.00 | 0.00 | 0.00 |
Average | 0.00 | 0.00 | 0.00 | 0.00 | |
02/11/2017 | Y | 45.00 | 0.00 | 7.50 | 45.00 |
02/18/2017 | Y | 45.00 | 0.00 | 4.00 | 45.00 |
02/25/2017 | Y | 43.00 | 0.00 | 5.00 | 43.00 |
03/04/2017 | Y | 21.00 | 0.00 | 2.00 | 21.00 |
Average | 38.50 | 0.00 | 4.63 | 38.50 |
Thanks for your help.
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.
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.
Available on demand!
Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.
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.