LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous (more recent) messageNext (less recent) messagePrevious (more recent) in topicNext (less recent) in topicPrevious (more recent) by same authorNext (less recent) by same authorPrevious page (September 2005, week 3)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Thu, 15 Sep 2005 14:58:31 -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: lead function
Comments: To: Urvir Palan <urbunti@YAHOO.COM>

Urvir,

Without getting into why you might want to do it, there are numerous ways. Retain within a datastep is definitely one, but most of the work would be maintaining your desired order.

data one; input cnt pct1 pct2; recnum=_n_; cards; 30 12 12 40 10 10 40 5 5 ; run; proc sort data=one; by descending recnum; run; data two (keep= recnum sumcnt sumpct1 sumpct2 rename=(sumcnt=cnt sumpct1=pct1 sumpct2=pct2)); retain sumcnt sumpct1 sumpct2; set one; if _n_ eq 1 then do; sumcnt=cnt; sumpct1=pct1; sumpct2=pct2; end; else do; sumcnt=sumcnt+cnt; sumpct1=sumpct1+pct1; sumpct2=sumpct2+pct2; end; run; proc sort data=two out=one (drop=recnum); by recnum; run;

Art ---------- On Thu, 15 Sep 2005 11:38:26 -0700, urbunti <urbunti@YAHOO.COM> wrote:

>I have a dataset > >cnt pct1 pct2 >30 12 12 >40 10 10 >40 5 5 > >i want >cnt pct1 pct2 >110 27 27 >80 15 15 >40 5 5


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