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 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
Comments: To: yoonsup@GMAIL.COM

Yoon,

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:

data test; input A B; cards; 0.73881725 0.564352457 0.522868443 0.45209803 0.95022985 0.953135437 0.618246892 0.573257113 0.983615318 0.199989929 0.506192327 0.825473437 0.006298226 0.800230824 0.478190999 0.104005372 0.429743949 0.257555838 0.412412675 0.328947322 ; run;

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 ; quit ;

HTH, Art -------- On Wed, 8 Aug 2007 08:08:40 -0700, yoonsup@gmail.com <yoonsup@GMAIL.COM> 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