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.
| Parameter | Description |
|---|---|
| source | Specifies the table whose rows will be appended. This can be an in-memory CAS table or a server-side file. |
| target | Specifies 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. |
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.
| 1 | DATA mycas.target_table; |
| 2 | SET sashelp.class(obs=5); |
| 3 | RUN; |
| 4 | |
| 5 | DATA mycas.source_table; |
| 6 | SET sashelp.class(firstobs=6 obs=10); |
| 7 | RUN; |
This example demonstrates how to append all rows from `source_table` to `target_table`. Both tables are in the active caslib.
| 1 | PROC CAS; |
| 2 | TABLE.append / |
| 3 | SOURCE={name='source_table'}, |
| 4 | target={name='target_table'}; |
| 5 | RUN; |
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`.
| 1 | PROC CAS; |
| 2 | TABLE.append / |
| 3 | SOURCE={name='source_table', where='Age > 13'}, |
| 4 | target={name='target_table'}; |
| 5 | RUN; |
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...
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...
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...