ADDROW Function

Adds one or more rows to a table.

Category:Result Tables
Returned data type:CAS table

Syntax

Required Argument

table

specifies the table to which rows are added. This argument can be any expression that results in a table.

Optional Argument

row-1, row-2, …, row-N

specifies one or more lists of column values to add as rows to the table. Each row argument can be any expression that results in a list of values. The lists are treated as arrays and values within the lists are assigned to columns in the table row in increasing array index order.

NoteAdding multiple rows in one function call is more efficient that specifying multiple function calls (one call for each row).

Details

Return Values

The following are the possible returned data values for the ADDROW function:

Return Values for the ADDROW Function

Return

Description

1

the ADDROW function succeeded.

CAS table

the ADDROW function failed to add the row or rows to the table.

Examples

Example 1: Add Three Rows to the Result Table

The rows job.result.tableName, job.result.caslib, and job.status.severity are added to the table results.

addrow(results,{job.result.tableName, job.result.caslib, job.status.severity});

Example 2: Create a New Table and Add Multiple Rows

This example shows how to create a table by using the NEWTABLE function and then add multiple rows to the table by using the ADDROW function. The program uses expressions as arguments for the row values in both the NEWTABLE and ADDROW functions. The example also shows how to efficiently add multiple rows in a single ADDROW function.

proc cas;

table_array[1] = newtable("Table1",{"x","y","z"},{"double","double","double"});
table_array[2] = newtable("Table2",{"x","y","z"},{"double","double","double"});

row_array = {
   { 1, 2, 3 },
   { 4, 5, 6 },
   { "x"=7, "z"=8, "y"=9 },
   { "z"=10, "y"=11, "x"=12 },
   { "y"=13, "z"=14, "x"=15 },
   { "x"=16, "z"=17, "y"=18 }
};

addrow( table_array[1], row_array[1] );
addrow( table_array[1], row_array[2] );
addrow( table_array[1], row_array[3] );

addrow( table_array[2], row_array[4] );
addrow( table_array[2], row_array[5] );
addrow( table_array[2], row_array[6] );

addrow( table_array[2], row_array[1], row_array[2], row_array[3] );

describe table_array[1];
print table_array[1];
run;

describe table_array[2];
print table_array[2];
run;

quit;
Last updated: August 18, 2026