READ_ARRAY Function

Reads data from a SAS data set into a PROC FCMP array variable.
Category: Array

Syntax

rc = READ_ARRAY(data_set_name, array_variable <, 'col_name_1', ..., 'col_name_n'>);

Required Arguments

rc
is 0 if the function is able to successfully read the data set.
data_set_name
specifies the name of the data set from which the array data will be read. data_set_name must be a character literal or variable that contains the member name (libname.memname) of the data set to be read from.
array_variable
specifies the PROC FCMP array variable into which the data is read. array_variable must be a local temporary array variable because the function might need to grow or shrink its size to accommodate the size of the data set.

Optional Argument

col_name
specifies optional names for the specific columns of the data set that will be read.
If specified, col_name must be a literal string enclosed in quotation marks. col_name cannot be a PROC FCMP variable. If column names are not specified, PROC FCMP reads all of the columns in the data set.

Details

When SAS translates between an array and a data set, the array will be indexed as [row,column].
Arrays that are declared in functions and CALL routines can be resized, as well as arrays that are declared with the /NOSYMBOLS option. No other arrays can be resized.
The READ_ARRAY function attempts to dynamically resize the array to match the dimensions of the input data set. This means that the array must be dynamic. That is, the array must be declared either in a function or CALL routine or declared with the /NOSYMBOLS option.

Example

This example creates and reads a SAS data set into an FCMP array variable.
data account;
   input acct price cost;
   datalines;
1 2 3
4 5 6
;
run;

proc fcmp;
   array x[2,3] / nosymbols;
   rc = read_array('account', x);
   put x=;
run;

proc fcmp;
   array x[2,2] / nosymbols;
   rc = read_array('account', x, 'price', 'acct');
   put x=;
run;
Output from the READ_ARRAY Function
                                 The SAS System                                1

                               The FCMP Procedure

x[1, 1]=1 x[1, 2]=2 x[1, 3]=3 x[2, 1]=4 x[2, 2]=5 x[2, 3]=6
                                 The SAS System                                2

                               The FCMP Procedure

x[1, 1]=2 x[1, 2]=1 x[2, 1]=5 x[2, 2]=4