I'm pretty sure that, when you evaluate something inside brackets like
in Ken's code, it returns a value of 1 for true and 0 for false. In
this case, when the code evaluates an 'a' value of 0.04 for example
(a<0.05), it 'resolves' to 1 if true. Then the sum function is simply
summing the resulting 1s and 0s for each condition across your
It's probably a bit counter-intuitive to use a sum when you want to
count, but they're the same thing when the only candidates for summing
are 1 or 0.
Does that help?
> Thanks all for your contribution.
> While I understand Tree Frog's code, Ken's code is not quite straight
> forward to me although it did what I wanted.
> In SAS's SQL procedure user guide, the aggregate function, "SUM" is
> described as "sum of values".
> With this, I'm guessing that Ken's advice on putting the condition
> directly to the aggregate function is supposed to
> sum up all the values that meet the condition in the parenthesis
> rather than counting them. However, it counts the number of rows
> that meet the condition, meaning Ken's code is just right for my
> question. What do I not understand here in "SUM" function?