Date: Mon, 17 Oct 2011 20:19:32 +0000
Reply-To: "Keintz, H. Mark" <mkeintz@WHARTON.UPENN.EDU>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: "Keintz, H. Mark" <mkeintz@WHARTON.UPENN.EDU>
Subject: Re: _TEMPORARY_ array initialization.
In-Reply-To: <CAEZCysvYm1aifnJMOpwy2TmOfBGp40A26A22VZiyomM+FEv=_g@mail.gmail.com>
Content-Type: text/plain; charset="us-ascii"
DN:
The behavior is the same for non-temporary arrays (below), which leads me to think that initialization takes place after the array is constructed (below).
Also, since arrays (temporary or regular) can be multi-dimensional, a list of initial values would be insufficient to determine array shape.
Regards,
Mark
380 data _null_;
9381 array x {*} x1-x3 (10 20 30);
9382 do I=1 to 3; put x{i}= +2 @; end;
9383 run;
x1=10 x2=20 x3=30
NOTE: DATA statement used (Total process time):
real time 0.02 seconds
cpu time 0.01 seconds
9384
9385 data _null_;
9386 array x {*} x1-x3 (10 20 30 40);
WARNING: Too many values for initialization of the array x. Excess values are ignored.
9387 do I=1 to 3; put x{i}= +2 @; end;
9388 run;
x1=10 x2=20 x3=30
NOTE: DATA statement used (Total process time):
real time 0.01 seconds
cpu time 0.01 seconds
9389
9390 data _null_;
9391 array x {*} x1-x3 (10 20);
WARNING: Partial value initialization of the array x.
9392 do I=1 to 3; put x{i}= +2 @; end;
9393 run;
x1=10 x2=20 x3=.
-----Original Message-----
From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On Behalf Of Data _null_;
Sent: Monday, October 17, 2011 3:39 PM
To: SAS-L@LISTSERV.UGA.EDU
Subject: _TEMPORARY_ array initialization.
SAS complains if the dimension of my _TEMPORARY_ doesn't match the initial values list so why cant I just leave the dimension off and use [*] like a variable based array. SAS is clearly counting the number of values in the initial values list so why can't that COUNT become the dimension.
125 data _null_;
126 array a[3] _temporary_ (10 20 30);
127 put a[1]= a[2]= a[3]=;
128 run;
a[1]=10 a[2]=20 a[3]=30
NOTE: DATA statement used (Total process time):
real time 0.00 seconds
cpu time 0.00 seconds
129
130 data _null_;
131 array a[3] _temporary_ (10 20 30 40);
WARNING: Too many values for initialization of the array a. Excess values are ignored.
132 put a[1]= a[2]= a[3]=;
133 run;
a[1]=10 a[2]=20 a[3]=30
NOTE: DATA statement used (Total process time):
real time 0.01 seconds
cpu time 0.01 seconds
134
135 data _null_;
136 array a[3] _temporary_ (10 20);
WARNING: Partial value initialization of the array a.
137 put a[1]= a[2]= a[3]=;
138 run;
a[1]=10 a[2]=20 a[3]=.
NOTE: DATA statement used (Total process time):
real time 0.01 seconds
cpu time 0.01 seconds
139
140 data _null_;
141 array a[*] _temporary_ (10 20 30);
ERROR: The non-variable based array a has been defined with zero elements.
142 put a[1]= a[2]= a[3]=;
ERROR: Too many array subscripts specified for array a.
ERROR: Too many array subscripts specified for array a.
ERROR: Too many array subscripts specified for array a.
143 run;
NOTE: The SAS System stopped processing this step because of errors.
NOTE: DATA statement used (Total process time):
real time 0.01 seconds
cpu time 0.01 seconds