Date: Tue, 11 Jul 2000 21:09:41 GMT
Reply-To: sashole@mediaone.net
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Paul Dorfman <paul_dorfman@HOTMAIL.COM>
Subject: Re: Missing Values within an array
Content-Type: text/plain; format=flowed
Garnett,
Try this:
87 data _null_;
88 array a(10) (0 1 2 3 4 . 6 7 8 9) ;
89 do i=lbound(a) to hbound(a) until (a(i) eq .); end;
90 if i le hbound(a) then a(i) = 5;
91 put a(*);
92 run;
0 1 2 3 4 5 6 7 8 9
Or if you have the liberty of allocating the array yourself, expand it an
extra slot to the right beforehand and populate the dummy slot with a
missing value. This renders the upper bound test redundant and speeds up the
code due to the elimination of the extra comparison from each iteration of
the loop:
99 data _null_;
100 array a(11) (0 1 2 3 4 . 6 7 8 9 .) ;
101 do i=lbound(a) by 1 until (a(i) eq .); end;
102 if i le hbound(a) then a(i) = 5;
103 put a1--a10;
104 run;
0 1 2 3 4 5 6 7 8 9
Kind regards,
=====================
Paul M. Dorfman
Jacksonville, Fl
=====================
>From: "Garnett P. McMillan" <gnet@UNM.EDU>
>Reply-To: "Garnett P. McMillan" <gnet@UNM.EDU>
>To: SAS-L@LISTSERV.UGA.EDU
>Subject: Missing Values within an array
>Date: Tue, 11 Jul 2000 12:53:59 -0600
>
>Hello!
>I need to find and modify the _first_ missing value in an array of
>numeric variables. Does anyone have a suggestion on how to do this?
>
>Thanks much!
>Garnett
________________________________________________________________________
Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com