```Date: Wed, 10 Mar 2004 16:25:26 +0100 Reply-To: "Groeneveld, Jim" Sender: "SAS(r) Discussion" From: "Groeneveld, Jim" Subject: Re: help to find the logic Comments: To: Vera Content-Type: text/plain; charset="iso-8859-1" Dear Vera, Try this (*tested*): data temp; infile cards; input v1-v10; cards; 2 2 4 5 4 2 4 3 2 2 ; RUN; DATA temp (DROP=I Found); SET temp; ARRAY Varray V1-V10; Found = 0; * Thus reset to 0 for every observation, no RETAIN; DO I = 2 TO 10; * !!! not 1 TO 10 !!!; IF Varray(I) EQ 2 AND Varray(I-1) EQ 4 THEN Found=1; IF Found THEN Varray(I) = 100; END; RUN; proc print data=temp; run; Regards - Jim. -- . . . . . . . . . . . . . . . . Jim Groeneveld, MSc. Biostatistician Science Team Vitatron B.V. Meander 1051 6825 MJ Arnhem Tel: +31/0 26 376 7365 Fax: +31/0 26 376 7305 Jim.Groeneveld@Vitatron.com www.vitatron.com My computer remains home, but I will attend SUGI 2004. [common disclaimer] -----Original Message----- From: Vera [mailto:vzamniborsch@HOTMAIL.COM] Sent: Wednesday, March 10, 2004 16:07 To: SAS-L@LISTSERV.UGA.EDU Subject: help to find the logic I am a student who is trying some SAS. The situation below is not a homework. I need to find a certain value (provided that it is not the first or consecutive to the first variable)in a series of consecutive variables and then to change it and the rest of the varibales values to something else. I tried array, but I cannot come up with the logic. Could somebody help me, please? Thank you, Vera. This is an example, where I need to find "2" that follows "4" (v1=2 and v2=2 are the first ones, so they don't count) and change them and the rest to 100. data temp; infile cards; input v1-v10; cards; 2 2 4 5 4 2 4 3 2 2 ; I need to have this: 2 2 4 5 4 100 100 100 100 100 ```

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