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 (March 2007, week 3)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Mon, 19 Mar 2007 11:43:41 -0400
Reply-To:     Gerhard Hellriegel <gerhard.hellriegel@T-ONLINE.DE>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         Gerhard Hellriegel <gerhard.hellriegel@T-ONLINE.DE>
Subject:      Re: A DATASET (probably retain statement) QUESTION

Or another way, if you don't want UNTIL...:

data work.player; input Player Score @@; cards; 1 1 2 1 2 2 2 2 3 1 3 1 3 2 3 2 3 3 3 6 4 6 4 6 4 6 4 6 4 6 ;;;; run;

proc sort; by player; run;

data res; set player; by player; retain sc n; if first.player then do; sc=0; n=0; end; sc=sc+(score=6); n+1; if last.player then do; if sc=n then flag="A"; if 0<sc<n then flag="B"; if sc=0 then flag="C"; output; end; run; proc print; run;

(for me not so elegant, but a bit easier to understand)

Gerhard

On Mon, 19 Mar 2007 10:06:59 -0400, data _null_; <datanull@GMAIL.COM> wrote:

>DO UNTIL(LAST is useful for this problem. > >data work.player; > input Player Score @@; > cards; >1 1 >2 1 2 2 2 2 >3 1 3 1 3 2 3 2 3 3 3 6 >4 6 4 6 4 6 4 6 4 6 >;;;; > run; >data work.score; > c6 = 0; > n = 0; > do until(last.player); > set work.player; > by player; > c6 + (score eq 6); > n + 1; > end; > flag = substr('ABC',(c6 eq 0) + (c6 gt 0)*2 + (c6 eq n),1); > *drop c6 n score; > run; >proc print; > run; > >On 3/19/07, Rathindronath <mehedisas@yahoo.com> wrote: >> I have a dataset as follows: >> >> Player Score >> ------ ------ >> 1 1 >> >> 2 1 >> 2 2 >> 2 2 >> >> 3 1 >> 3 1 >> 3 2 >> 3 2 >> 3 3 >> 3 6 >> >> 4 6 >> 4 6 >> 4 6 >> 4 6 >> 4 6 >> >> The conditions are as follows: >> --------------------------------- >> if every score is 6 for a patient then flag = A >> if some scores are 6 ( but not all)for a patient then flag = B >> if none score is 6 for a patient then flag = C >> >> >> I need a dataset as follows (RESULT): >> ------------------------------ >> >> Patient Score >> ------- ----- >> 1 C >> 2 C >> 3 B >> 4 A >> >> >> Thanks in advance for your kind help. >>


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