[prev in list] [next in list] [prev in thread] [next in thread] 

List:       sas-l
Subject:    Re: Can this be done in data step
From:       Joe Whitehurst <joewhitehurst () GMAIL ! COM>
Date:       2009-10-31 21:01:28
Message-ID: 129a50e0910311401q35938cacv298379ab098c5eb2 () mail ! gmail ! com
[Download RAW message or body]

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
>
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic