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 (May 2005, week 4)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Thu, 26 May 2005 14:37:47 -0400
Reply-To:     "Howard Schreier <hs AT dc-sug DOT org>" <nospam@HOWLES.COM>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         "Howard Schreier <hs AT dc-sug DOT org>" <nospam@HOWLES.COM>
Subject:      Re: problem in taking sum

PROC SUMMARY by default complains that you did not tell it to output anything. Try

proc summary data=sashelp.class; run;

Log reads:

ERROR: Neither the PRINT option nor a valid output statement has been given.

Att he very least it requires

proc summary data=sashelp.class print; run;

or

proc summary data=sashelp.class; output; run;

On Thu, 26 May 2005 16:13:38 +0000, toby dunn <tobydunn@HOTMAIL.COM> wrote:

>Nat, > >Proc means default adtion is to create a report and proc summarys default >action is to create a dataset. Thus IMHO it is far better to use proc >summary rather than proc means as the intent of the code becomes clearer. >On the other hand I personally wouldn't use either one but rather the SQL >code, my preference, and as you have shown runs faster. > > > >Toby Dunn > > > > >From: Nat Wooding <Nathaniel_Wooding@DOM.COM> >Reply-To: Nathaniel_Wooding@DOM.COM >To: SAS-L@LISTSERV.UGA.EDU >Subject: Re: problem in taking sum >Date: Thu, 26 May 2005 12:04:23 -0400 >Since this was a case where we had Proc Means and SQL solutions, I thought >it would be fun to do a quick shootoff so I added some records to the >original file > >data a; > input ID Amount Date mmddyy10.; > format date mmddyy10.; >cards; >1 20 04031996 >1 10 12021996 >1 30 04011997 >2 40 04071996 >2 50 04021996 >proc print; >data a; > set ; > do id=1 to 100000; > output; > end; > >proc sql ; >create table Sum1 as > select ID , Sum(Amount) as Amount , Max(Date) as Date > from a > group by ID ; >quit ; >proc means data=a MISSING NONOBS NOPRINT; > class ID; > id Date; > > output out=summary_data(drop= _type_ _freq_ where=( id)) > sum(Amount)=sum_amount > ; >run; > > > >The log results were > > >NOTE: PROCEDURE SQL used (Total process time): > real time 5.76 seconds > cpu time 1.88 seconds > > >(snip) > >NOTE: There were 500000 observations read from the data set WORK.A. >NOTE: The data set WORK.SUMMARY_DATA has 100000 observations and 3 >variables. >NOTE: PROCEDURE MEANS used (Total process time): > real time 3.33 seconds > cpu time 3.15 second > > >so take your pick depending on your resources. > >Nat > > > > toby dunn > <tobydunn@HOTMAIL To: >SAS-L@LISTSERV.UGA.EDU > .COM> cc: > Sent by: "SAS(r) Subject: Re: problem in >taking sum > Discussion" > <SAS-L@LISTSERV.U > GA.EDU> > > > 05/26/05 11:47 AM > Please respond to > toby dunn > > > > > > >Vinoth, > >data one ; >infile cards ; >input ID Amount Date ; >cards; >1 20 04031996 >1 10 04021996 >1 30 04011996 >2 40 04071996 >2 50 04021996 >; >run; > >/**********************************/ >/** SQL Solution **/ >/**********************************/ > >proc sql ; >create table Sum1 as > select ID , Sum(Amount) as Amount , Max(Date) as Date > from one > group by ID ; >quit ; > > >/**********************************/ >/** Data Step Solution **/ >/**********************************/ > >proc sort >data = one ; >by ID Date ; >run ; > >data Sum2 (drop = _Amount) ; >set one (rename = (Amount = _Amount)) ; >by ID Date ; > >Amount + _Amount ; > >If last.ID then do ; >Output ; >Amount = 0 ; >end ; > >run ; > > >/***********************************/ >/** Proc Means Solution **/ >/***********************************/ > >Proc Means >data = one nway noprint ; >by ID ; >var Amount ; >output out = Sum3 (Drop = _type_ _freq_ ) > sum = Amount max(Date) = Date; >run ; > > >/***********************************/ >/** Proc Summary Solution **/ >/***********************************/ > >Proc Summary > data = one nway ; > by ID ; > Var Amount ; > output out = Sum4 (Drop = _type_ _freq_ ) > sum = Amount max(Date) = Date ; >run ; > >/***************************************/ >/** DOW Solution **/ >/***************************************/ > >proc sort >data = one ; >by ID Date ; >run ; > >data sum5 (drop = _Amount) ; >Amount = 0 ; > >do until (last.ID) ; >set one (rename = (Amount = _Amount)) ; >by ID ; >Amount + _Amount ; >end ; > >run ; > > > >Toby Dunn > > > > >From: vinoth babu <way2vb@YAHOO.COM> >Reply-To: vinoth babu <way2vb@YAHOO.COM> >To: SAS-L@LISTSERV.UGA.EDU >Subject: problem in taking sum >Date: Thu, 26 May 2005 09:03:04 +0100 > > >Hi, > >I have dataset having multiple records per repondence. >It looks like the below dataset. > >ID Amount Date >1 20 04031996 >1 10 04021996 >1 30 04011996 >2 40 04071996 >2 50 04021996 > >I need dataset having unique ID value and sum of the >amount and recent date. > >Result should be > >ID Amount Date >1 60 04031996 >2 90 04071996 > >Any ideas > >Thanks > > > VB > > >________________________________________________________________________ >Yahoo! India Matrimony: Find your life partner online >Go to: http://yahoo.shaadi.com/india-matrimony > > > > >----------------------------------------- >CONFIDENTIALITY NOTICE: This electronic message contains information >which may be legally confidential and/or privileged and does not in any >case represent a firm ENERGY COMMODITY bid or offer relating thereto >which binds the sender without an additional express written >confirmation to that effect. The information is intended solely for >the individual or entity named above and access by anyone else is >unauthorized. If you are not the intended recipient, any disclosure, >copying, distribution, or use of the contents of this information is >prohibited and may be unlawful. If you have received this electronic >transmission in error, please reply immediately to the sender that you >have received the message in error, and delete it. Thank you.


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