Date: Wed, 2 Jul 2008 04:08:25 +0000
Reply-To: toby dunn <tobydunn@HOTMAIL.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: toby dunn <tobydunn@HOTMAIL.COM>
Subject: Re: Null values in arrays
Content-Type: text/plain; charset="iso-8859-1"
Tedious yes I agree manually writting all those if statements would be tedious to say the least. Inefficient is something that needs to be discussed. What amazes me is you talk about efficiency but have restructured your data in one of if not the most ineeficient structures for SAS to process. If one were too look under the hood of SAS, if you will, one would see that SAS's underling code prefers normalized data structures. But that is if we are talking about program speed, which should be more often than not the last thing you think about unless you work with data that has to be talked about in the Billions of observations. Speed in programming was a big deal when computers used vaccum bulbs and one wrote code on punch cards. Id prefer not to deal with call poke and peek as Poke in unitiated hands has the propensity to cause more problems than not. Knowing Paul well I would have no problem with him using it, but I dont let my programmers in my shop use it for safety reasons.
Here is the simple form of Pauls code using a simple do loop:
data miss ;
input ID sva_1 - sva_9 ;
101 1 2 2 3 4 6 8 9 10
102 2 3 4 4 4 6 . . .
103 3 . . . . . . . .
Data Need ( Drop = I ) ;
Set Miss ;
Array SVA ( * ) SVA_: ;
Do I = 1 To Dim( SVA ) ;
If ( Missing( SVA( I ) ) ) Then SVA( I ) = 0 ;
"Don't bail. The best gold is at the bottom of barrels of crap."
"Be prepared. Luck is where preparation meets opportunity."
> Date: Tue, 1 Jul 2008 13:34:08 -0700
> From: krutic@GMAIL.COM
> Subject: Null values in arrays
> To: SAS-L@LISTSERV.UGA.EDU
> I have the following data in a sas dataset. The dataset is created by
> transposing the raw data to get one record per customer.
> SVA_ is an array that stores a dynamic number of values for SVA.
> The array is SVA_1 - SVA_&total.
> For example in the below sample..SVA values are from SVA_1 - SVA_9 but
> it can be SVA_1 - SVA_40 depending on the incoming dataset.
> ID SVA_1 SVA_2 SVA_3 SVA_4 SVA_5 SVA_6 SVA_7 SVA_8 SVA_9
> 101 1 2 2 3 4 6 8
> 9 10
> 102 2 3 4 4 4
> 6 . . .
> 3 . . . . . . . .
> I need to find a way to replace all the SVA values that are null with
> a 0 (zero). I can't do it manually because it would be too tedious and
> I have 4 other variables like SVA so it would be way too inefficient
> to do something like if SVA_2 = . then SVA_2 = 0.
> Is there a better way to do this? Some sort of array processing that
> can assign 0 to null values in one step?
> Thank you!
Making the world a better place one message at a time.