Date: Thu, 13 Feb 1997 21:07:31 +0100
Reply-To: ehoogenb@solair1.inter.nl.net
Sender: "SAS(r) Discussion" <SAS-L@UGA.CC.UGA.EDU>
From: Eric Hoogenboom <ehoogenb@SOLAIR1.INTER.NL.NET>
Organization: NLnet
Subject: Re: - SQL group by - problem
Content-Type: text/plain; charset=us-ascii
mik wrote:
>
> I'm having a problem with SAS-sql. I would like my proc SQL to do the
> same as my proc summary
>
> proc summary data=name;
> by group;
> var amount;
> id name;
> output out=name2 sum(amount)=total;
> run;
>
> Result (name2) :
>
> Group Name Total
> 1 Sue 30
> 2 Sue 70
>
(...)
I wouldn't know why you should exclude John from your output, but when
you want only one name with the group, why not use the MAX or MIN
function:
select group, max(name) as name, sum(amount) as total
from name
group by group;
When you group by group you do not have to order by group as far as I am
concerned.
Hope this helps,
Eric.
|