Loads a table from a caslib's data source into memory on the CAS server. This action is fundamental for making external data available for analysis in CAS. It supports various file types like CSV, SASHDAT, Parquet, and Excel, and allows for customization through import options.
| Parameter | Description |
|---|---|
| attrTable | Specifies the name of an existing extended attributes table to use. |
| caslib | Specifies the caslib for the data source to load the file from. If not specified, the active caslib is used. |
| casOut | Specifies the properties of the output in-memory table, such as its name, caslib, and whether to replace an existing table. |
| dataSourceOptions | Provides options for data sources like databases (e.g., Oracle, Teradata) or Hadoop. For file-based caslibs like PATH, this is not typically used. |
| importOptions | Specifies the settings for reading the data, which depend on the file type. For example, for a CSV, you can specify the delimiter. |
| loadAttrs | When set to True, automatically loads attributes from a corresponding .ATTRS.sashdat file. |
| maximumRecords | Specifies the maximum number of records to load from the source file. |
| path | Specifies the file name (or path) within the caslib's data source to load. |
| promote | When set to True, the loaded table is made available to all sessions (global scope), not just the current session. |
| readAhead | When set to True, loads the table into memory immediately, rather than waiting for it to be first used. |
| vars | Allows for modification of variable properties like format, label, and length during the load process. |
| where | Specifies an expression for subsetting the data as it is loaded from the source file. |
This SAS code snippet creates a simple CSV file named 'cars.csv' in the '/cas/data/' directory, which is accessible by the CAS server. This file will be used as the source for the loadTable action in the examples.
| 1 | DATA _null_; |
| 2 | file '/cas/data/cars.csv' dsd dlm=','; |
| 3 | put 'Make,Model,Type,EngineSize,Cylinders,Horsepower,MPG_City,MPG_Highway,Weight,Wheelbase,Length'; |
| 4 | put 'Acura,MDX,SUV,3.5,6,265,17,23,4451,106,189'; |
| 5 | put 'Audi,A4 1.8T 4dr,Sedan,1.8,4,170,22,31,3252,104,179'; |
| 6 | put 'BMW,325i 4dr,Sedan,2.5,6,184,20,30,3219,107,176'; |
| 7 | RUN; |
This example loads the 'cars.csv' file from the 'CASUSER' caslib into an in-memory table named 'CARS_TABLE'. The table will be local to the current session.
| 1 | |
| 2 | PROC CAS; |
| 3 | TABLE.loadTable / caslib='CASUSER' path='cars.csv' casOut={name='CARS_TABLE'}; |
| 4 | |
| 5 | RUN; |
| 6 |
This example loads the 'cars.csv' file but also uses the `importOptions` parameter to specify the file type explicitly. The `casOut` parameter specifies a new table name 'CARS_GLOBAL', includes a descriptive label, and uses `promote=TRUE` to make the table accessible to all sessions.
| 1 | |
| 2 | PROC CAS; |
| 3 | TABLE.loadTable / caslib='CASUSER' path='cars.csv' casOut={name='CARS_GLOBAL', label='Global Cars |
| 4 | Data', promote=TRUE} importOptions={fileType='CSV'}; |
| 5 | |
| 6 | RUN; |
| 7 |
This example loads a SASHDAT file named 'mydata.sashdat' from the 'Public' caslib. The resulting in-memory table is named 'PROMOTED_TABLE' and is promoted to global scope for use in other sessions.
| 1 | |
| 2 | PROC CAS; |
| 3 | TABLE.loadTable / caslib='Public' path='mydata.sashdat' casOut={name='PROMOTED_TABLE', promote=TRUE}; |
| 4 | |
| 5 | RUN; |
| 6 |