LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous messageNext messagePrevious in topicNext in topicPrevious by same authorNext by same authorPrevious page (August 2007, week 2)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:   Wed, 8 Aug 2007 16:09:07 -0700
Reply-To:   Tree Frog <tree.frog2@HOTMAIL.COM>
Sender:   "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:   Tree Frog <tree.frog2@HOTMAIL.COM>
Subject:   Re: counting rows with condition
Comments:   To:
In-Reply-To:   <>
Content-Type:   text/plain; charset="us-ascii"

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 dataset.

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?

TF wrote: > 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? > > Thanks. > > Yoon

Back to: Top of message | Previous page | Main SAS-L page