/***************************************************************************************************************** SAS file name: Array_Implicit_Explicit.sas File location: __________________________________________________________________________________________________________________ Purpose: To demonstrate the difference between the Explicit and Implicit array in SAS Author: Peter Clemmensen Creation Date: 19Aug2019 This program supports the blog post "Implicit Vs Explicit Arrays in SAS" on SASnrd.com *****************************************************************************************************************/ /* Explcit Array */ data _null_; array a {5} a1-a5 (5*1); a[3]=10; b=a[3]; put b= //; do x=1 to dim(a); put (a[x])(=); end; run; /* Implicit Array */ data _null_; array a (i) a1-a5 (2 4 6 8 10); i=3; put a=; /* b=a[1]; ERROR: Mixing of implicit and explicit array subscripting is not allowed. */ run; /* Do Over Example */ data _null_; array a (i) a1-a5 (1:5); do i=1 to dim(a); put a=; end; do over a; put a=; end; run; /* Nesting Do Over Loops */ data _null_; array a (i) a1-a5 (1:5); array b (j) b1-b5 (6:10); do over a; do over b; put a= b=; end; end; run; /* The _I_ variable */ data _null_; array a a1-a5 (2 4 6 8 10); do over a; put @3 a= @10 _I_=; end; run; /* Implicit arrays can contain Other implicit arrays */ data _null_; array a (i) a1-a5 (1:5); array b (i) b1-b5 (6:10); array ab a b; do over ab; do i=1 to 5; put ab=; end; end; run;