table

append

Description

The `append` action adds the rows from a source table to the end of a target table. It is a versatile tool for combining datasets within the CAS environment. The target table must be an in-memory table, while the source can be an in-memory table or a server-side file that has not been loaded. This action is particularly useful in data preparation workflows where data from multiple sources needs to be consolidated into a single table for analysis.

table.append { source={...}, target={...} };
Settings
ParameterDescription
sourceSpecifies the table whose rows will be appended. This can be an in-memory CAS table or a server-side file.
targetSpecifies the in-memory table to which the rows will be added. This table must already exist.
caslib(Within source or target) Specifies the caslib for the table. If omitted, the active caslib is used.
name(Within source or target) Specifies the name of the table.
dataSourceOptions(Within source) Specifies data source options when the source is a server-side file.
singlePass(Within source) When set to True, specifies not to create a transient table on the server, which can be more efficient but might result in non-stable ordering on repeated runs.
where(Within source) Specifies an expression for subsetting the data from the source table before appending.
Data Preparation View data prep sheet
Data Creation

The following code creates two tables, `target_table` and `source_table`, in the active caslib. `target_table` contains initial data, and `source_table` contains the data to be appended.

Copied!
1DATA mycas.target_table;
2 SET sashelp.class(obs=5);
3RUN;
4 
5DATA mycas.source_table;
6 SET sashelp.class(firstobs=6 obs=10);
7RUN;

Examples

This example demonstrates how to append all rows from `source_table` to `target_table`. Both tables are in the active caslib.

SAS® / CAS Code Code awaiting community validation
Copied!
1PROC CAS;
2 TABLE.append /
3 SOURCE={name='source_table'},
4 target={name='target_table'};
5RUN;
Result :
The rows from `source_table` are added to the end of `target_table`. The target table will now contain the combined rows from both original tables.

This example shows how to append only a subset of rows from the source table. The `where` parameter is used to select only the rows where the 'Age' is greater than 13 from `source_table` before appending them to `target_table`.

SAS® / CAS Code Code awaiting community validation
Copied!
1PROC CAS;
2 TABLE.append /
3 SOURCE={name='source_table', where='Age > 13'},
4 target={name='target_table'};
5RUN;
Result :
Only the rows from `source_table` that satisfy the condition 'Age > 13' are appended to `target_table`. The target table will contain its original rows plus the filtered rows from the source.

FAQ

What is the primary function of the `table.append` action in SAS Viya?
What are the mandatory parameters for the `table.append` action?
How can I append only a specific subset of a source table?
What does the `singlePass` parameter do within the `source` table specification?
Is it possible to use data source-specific options when appending a table?

Associated Scenarios

Use Case
Standard Case: Consolidating Daily Customer Interactions for Marketing Analysis

A marketing department needs to consolidate daily customer web interaction logs into a master historical table. To comply with privacy regulations, only interactions from custom...

Use Case
Performance Test: High-Volume Ingestion of IoT Sensor Data

A manufacturing company needs to ingest millions of sensor readings from its assembly line into a central CAS table for real-time anomaly detection. Performance is critical to e...

Use Case
Edge Case: Reconciling Financial Ledgers with Mismatched Columns and Missing Data

An accounting department is consolidating transaction records from a subsidiary's ledger into the company's general ledger. The subsidiary's system includes extra, non-financial...