Search code examples
sas

Array and CALL dynamic_array in SAS SQL


I'm having trouble with understanding this piece of code:

array arname[1] / nosym;
call dynamic_array(arname,10)

Does the first line create a one-dimensional array and the second one creates a multidimensional (10) array?


Solution

  • The first statement defines arname as a temporary array with 1 element.

    The second statement redefines arname as an array with 10 elements. The existing elements are preserved.

    Resizeable arrays are only possible within the context of a FCMP function or call routine, and are not part of the DATA Step language. FCMP functions can be invoked from DATA Step or Proc SQL.

    Proc FCMP ARRAY Statement

    /NOSYMBOLS is used in exactly the same way as _TEMPORARY_.

    FCMP Special Functions and Call Routines - CALL DYNAMIC_ARRAY Routine

    CALL DYNAMIC_ARRAY(array–name, new-dimension1–size <, new-dimension2–size, ...>);
    ...
    The DYNAMIC_ARRAY CALL routine attempts to dynamically resize the array to match the dimensions of the target that you provide. This means that the array must be dynamic. That is, the array must be declared either in a function or subroutine, or declared with the /NOSYMBOLS option.