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 (October 2009, week 5)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:   Sat, 31 Oct 2009 17:01:28 -0400
Reply-To:   Joe Whitehurst <joewhitehurst@GMAIL.COM>
Sender:   "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:   Joe Whitehurst <joewhitehurst@GMAIL.COM>
Subject:   Re: Can this be done in data step
Comments:   To: Paul Dorfman <sashole@bellsouth.net>
In-Reply-To:   <200910312057.n9VBCDVL014110@mailgw.cc.uga.edu>
Content-Type:   text/plain; charset=ISO-8859-1

With minds like this under "their" control, I just cannot understand how "they" allowed the Wall to Fall!

On Sat, Oct 31, 2009 at 4:57 PM, Paul Dorfman <sashole@bellsouth.net> wrote:

> Bunti, > > I bet another way out of 3 alluded to by Toby, in addition to one shown by > Art, would be something akin to: > > data another_tobi_way (drop = _:) ; > if _n_ = 1 then do until (z) ; > set table (keep = sal) end = z ; > _sum ++ sal ; > end ; > set table ; > if _sum then pct_sum = sal / _sum * 100 ; > run ; > > If you are curious about other possible variations, Art's step can be coded > slightly differently as well: > > data yet_another_way ; > do _n_ = 0 by 0 until (z) ; > set table (keep = sal) end = z ; > _n_ ++ sal ; > end ; > do while (1) ; > set table ; > if _n_ then pct_sum = sal / _n_ * 100 ; > output ; > end ; > run ; > > Here the idle auto-variable _N_ is used as an accumulator. BY 0 makes sure > the first loop iterates more than once. The DATA step, together with the > second loop, ceases and desists when the second SET attempts to read from > its already empty buffer. > > Kind regards > ------------ > Paul Dorfman > Jax, FL > ------------ > > On Sat, 31 Oct 2009 11:49:03 +0530, Bunti <urbunti@YAHOO.COM> wrote: > > >All, > > > >I was wondering if below code can be done in data step > > > >proc sql; > >select *, (sal*100)/sum(sal) from table; > >quit; > > > >table is something like this > > > >name sal > >a 100 > >b 200 > >c 300 > > > > > >Regards, > >Urvir > > > Keep up with people you care about with Yahoo! India Mail. Learn how. > http://in.overview.mail.yahoo.com/connectmore >


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