Date: Wed, 8 Aug 2007 18:43:53 -0400
Reply-To: Arthur Tabachneck <art297@NETSCAPE.NET>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Arthur Tabachneck <art297@NETSCAPE.NET>
Subject: Re: counting rows with condition
While you indicated that Ken's code already provided the results you
wanted, most of the following will probably be irrelevant.
Someone pointed out that you might actually have wanted the number of rows
that ONLY fall between the various ranges.
Since Ken's code was simply providing the sums of ones that met the
various logical conditions, you could easily expand the code to get
discrete sums of the various conditions with something like:
input A B;
proc sql ;
select sum(a<.01) as A_lt_p01,
sum(.01<a<.05) as A_lt_p05,
sum(.05<a<.25) as A_lt_p25,
sum(.25<a<.5) as A_lt_p50,
sum(b<.01) as B_lt_p01,
sum(.01<b<.05) as B_lt_p05,
sum(.05<b<.25) as B_lt_p25,
sum(.25<b<.5) as B_lt_p50
/* you get the picture */
from test ;
On Wed, 8 Aug 2007 08:08:40 -0700, email@example.com <yoonsup@GMAIL.COM>
>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?