Date: Wed, 8 Aug 2007 18:43:53 -0400 Reply-To: Arthur Tabachneck Sender: "SAS(r) Discussion" From: Arthur Tabachneck 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 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