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 (June 2004, week 4)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Tue, 22 Jun 2004 16:31:30 -0400
Reply-To:     Howard Schreier <Howard_Schreier@ITA.DOC.GOV>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         Howard Schreier <Howard_Schreier@ITA.DOC.GOV>
Subject:      Re: Help with By group processing, thanks

Some of the other solutions are better, but here's the one you almost had on your own.

Uncomment the IF statement in your last DATA step and code a DROP= option for the disaggregated variable:

data gettotal(drop = fund); set ttotalsorted; by inst; if first.inst then totfund = 0; totfund + fund; if last.inst; run;

Then merge the totals back with the disaggregated data:

data want; merge ttotalsorted gettotal; by inst; run;

On Tue, 22 Jun 2004 06:29:43 -0700, SAS L <sasluser@YAHOO.COM> wrote:

>Hey, all: > >I am having some problem with a by - group processing, or you may have some alternatives to solve this problem. > >Run this program below you will get: > >inst fund totfund >FDA 4 4 >FDA 41 45 >FDA 3 48 >HIB 10 10 >NCI 5 5 >NIH 4 4 >NIH 50 54 > >and what I eventually want is something like this: >inst fund totfund >FDA 4 48 >FDA 41 48 >FDA 3 48 >HIB 10 10 >NCI 5 5 >NIH 4 54 >NIH 50 54 > >Thank you very much!!!!!!! > >SCh > > >data ttotal; > input inst $ fund; > cards; > FDA 4 > FDA 41 > FDA 3 > NIH 4 > NIH 50 > NCI 5 > HIB 10 > ; >run; >proc sort data = ttotal out = ttotalsorted; >by inst; >run; >data gettotal; > set ttotalsorted; > by inst; > if first.inst then totfund = 0; > totfund + fund; > *if last.inst; >run; >proc print data = gettotal; >run; > > > > >--------------------------------- >Do you Yahoo!? >New and Improved Yahoo! Mail - Send 10MB messages!


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