Date: Thu, 23 Jun 2005 08:05:47 +0000
Reply-To: Guido T <cymraeg_erict@HOTMAIL.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Guido T <cymraeg_erict@HOTMAIL.COM>
Subject: Re: Array problem
In-Reply-To: <42BA6B13.9070204@uaa.alaska.edu>
Content-Type: text/plain; format=flowed
Hi David,
... wood for trees ...(sigh). I think just defining the array "the other way
round", would have been a *better* thing to do. Then the loop can go in the
normal, incrementing, way. But there's no big difference (6 fewer
characters), so long as the first non-zero element of the array is the one
we want.
Well, it was the first thing in the morning and I hadn't finished my coffee
...
++ Guido
>From: David Neal <afdbn@UAA.ALASKA.EDU>
>Reply-To: David Neal <afdbn@UAA.ALASKA.EDU>
>To: SAS-L@LISTSERV.UGA.EDU
>Subject: Re: Array problem
>Date: Wed, 22 Jun 2005 23:56:03 -0800
>
>Stepping backwards through the array is probably a better way to do this
>the one I suggested, unless you are going to be doing other calculations
>such as creating a variable for total due etc. With a huge number of
>observations you would probably want to optimize as much as possible.
>
>David
>
>Guido T wrote:
>
>>Hi Paul,
>>
>>Given that you have you data in one record there are a number of things
>>you
>>could do.
>>One I would suggest looping down and lexit the loop when you find the
>>first
>>non-zero element.
>>
>>You could use something like this ...
>>
>> do i=dim(testArray) to 1 by -1;
>> if testArray[i] le 0 then continue;
>> myTestVar = testArray[i];
>> leave;
>> end;
>>
>>Note:
>> CONTINUE goes to the bottom of the DO loop.
>> LEAVE goes to the first statement after the DO block.
>>
>>Or perhaps ...
>>
>> do i=dim(testArray) to 1 by -1 until(testArray[i] gt 0);
>> end;
>> if i>0 then myTestVar = testArray[i];
>>
>>Not that I would ever code anything like this.
>>
>>HTH
>>++ Guido
|