/***************************************************************************************************************** SAS file name: array_zero File location: _________________________________________________________________________________________________________________ Purpose: To demonstrate how to set all array elements to zero during execution in a data step. Author: Peter Clemmensen Creation Date: 19/06/2019 This program supports the example page "Set All Array Elements to Zero in SAS" on SASnrd.com *****************************************************************************************************************/ /* Go through each element and set to zero */ data _null_; array x[10] (1 . 3 . 5 . 7 . 9 .); do i=1 to dim(x); x[i]=0; end; put x[*]; run; /* Use Call Stdize */ data _null_; array x[10] (1 . 3 . 5 . 7 . 9 .); call stdize('replace','mult=',0,of x[*],_N_); put x[*]; run; /* Use Call Fillmatrix thrugh PROC FCMP*/ proc fcmp outlib=work.functions.fun; subroutine fillarray (x[*], value); outargs x; call fillmatrix (x, value); endsub; quit; option cmplib=work.functions; data _null_; array x[10] _temporary_ (1 . 3 . 5 . 7 . 9 .); call fillarray (x, 0); temp=catq('d', ' ', of x[*]); put temp=; run;