```Date: Tue, 7 Jun 2005 17:48:32 -0400 Reply-To: BJ Mattson Sender: "SAS(r) Discussion" From: BJ Mattson Subject: Re: Help with Coding On Tue, 7 Jun 2005 13:25:46 -0700, data _null_; wrote: >BJ it appears that you have a small bug associated with > array dose (5) dose_1 dose_2 dose_3 dose_4 dose_5 (0 0 0 0 0); >ID 101 did not take any drug in month 1 and 2 >ID 103 did not take any drug in month 1,2 and 3. >>From the online DOC. > >Tip: When any (or all) elements are assigned initial values, all >elements behave as if they had been named one a RETAIN statement. Apologies. Fixed it as follows: data work.drug; input ID A100_1 A100_2 A100_3 A100_4 A100_5 A150_1 A150_2 A150_3 A150_4 A150_5 A200_1 A200_2 A200_3 A200_4 A200_5 ; array A100 (5) A100_1 A100_2 A100_3 A100_4 A100_5; array A150 (5) A150_1 A150_2 A150_3 A150_4 A150_5; array A200 (5) A200_1 A200_2 A200_3 A200_4 A200_5; array dose (5) dose_1 dose_2 dose_3 dose_4 dose_5; do i = 1 to 5; dose (i) = .; /* unless you want it as a 0 - either works */ if A100(i) = 1 then dose (i) = 100; else if A150(i) = 1 then dose (i) = 150; else if A200(i) = 1 then dose (i) = 200; end; datalines; 100 1 0 0 0 0 0 1 1 1 0 0 0 0 0 1 101 0 0 1 1 1 0 0 0 0 0 0 0 0 0 0 102 1 1 0 0 0 0 0 0 0 0 0 0 1 1 1 103 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 104 1 1 1 0 0 0 0 0 0 0 0 0 0 1 1 ;;;; run; proc print; run; ```

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