```Date: Mon, 19 Mar 2007 11:43:41 -0400 Reply-To: Gerhard Hellriegel Sender: "SAS(r) Discussion" From: Gerhard Hellriegel 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 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 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