WRITE_ARRAY

Writes data from a PROC FCMP array variable to a data set that can then be used by SAS programs, macros, and procedures.
Category: Array
Note: When SAS translates between an array and a data set, the array will be indexed as [row, column].

Syntax

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

Required Arguments

rc
is 0 if the function is able to successfully write the data set.
data_set_name
specifies the name of the data set to which the array data will be written. data_set_name must be a character literal or variable that contains the member name (libname.memname) of the data set to be created.
array_variable
specifies the PROC FCMP array or matrix variable whose contents will be written to data_set_name.

Optional Argument

col_name
specifies optional names for the columns of the data set that will be created.
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, the column name will be the array name with a numeric suffix.

Examples

Example 1: Using the WRITE_ARRAY Function with a PROC FCMP Array Variable

This example uses the ARRAY statement and the WRITE_ARRAY function with PROC FCMP to write output to a data set.
options nodate pageno=1 ls=80 ps=64;

proc fcmp;
   array x[4,5] (11 12 13 14 15 21 22 23 24 25 31 32 33 34 35 41 42 43 44 45);
   rc = write_array('work.numbers', x);
run;

proc print data = work.numbers;
run;
Output from Using the WRITE_ARRAY Function
                         The SAS System                                       1
                    Obs    x1    x2    x3    x4    x5

                        1     11    12    13    14    15
                        2     21    22    23    24    25
                        3     31    32    33    34    35
                        4     41    42    43    44    45

Example 2: Using the WRITE_ARRAY Function to Specify Column Names

This example uses the optional colN variable to write column names to the data set.
options pageno=1 nodate ps=64 ls=80;

proc fcmp;
   array x[2,3] (1 2 3 4 5 6);
   rc = write_array('numbers2', x, 'col1', 'col2', 'col3');
run;

proc print data = numbers2;
run;
Output from Using the WRITE_ARRAY Function to Specify Column Names
                             The SAS System                                1

                          Obs    col1    col2    col3

                           1       1       2       3
                           2       4       5       6