Date: Mon, 11 Oct 1999 12:48:21 -0400 Julia Hertl "SAS(r) Discussion" Julia Hertl SOLVED: Looking at 5 consecutive observations text/plain; charset="us-ascii"

Hi SAS-L, Many thanks for all the great solutions to this problem. We ended up using Ian Whitlock's solution:

data cows ; input COW DIM PROG ; cards ; 1 14 410 1 16 450 1 18 520 1 21 600 1 23 590 1 25 610 1 28 660 1 30 490 1 32 510 1 35 540 1 37 550 1 39 520 1 41 550 2 13 420 2 15 510 2 17 530 2 20 550 2 22 420 2 24 520 2 27 530 2 29 540 2 31 560 2 34 570 3 13 450 3 15 400 3 17 550 3 19 520 3 22 380 3 24 500 3 26 340 ;

data cycles ( keep = cow cycle ) ; retain cycle ; set cows ; by cow ; if first.cow then cycle = . ; if prog >= 500 and cycle = . then do ; cycle = dim ; cnt = 0 ; end ; cnt + 1 ; if cnt <= 4 and prog < 500 then cycle = . ; if last.cow ; run ;

data cows ; merge cows cycles ; by cow ; run ;

It worked perfectly! Thanks again.

Julia Hertl Section of Epidemiology Dept. of Population Medicine and Diagnostic Sciences College of Veterinary Medicine Cornell University Ithaca, NY 14853

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