table

fileInfo

Description

The fileInfo action lists the files in a caslib's data source. It provides detailed metadata about files, including permission, owner, group, size, and modification time. This action is essential for exploring available data files and can calculate row counts for supported file types. You can use wildcard characters to filter the file list based on name patterns.

table.fileInfo <result=results> <status=rc> / allFiles=TRUE | FALSE, caslib="string", dataSourceOptions={adls-parameters | bigquery-parameters | ...}, includeDirectories=TRUE | FALSE, kbytes=TRUE | FALSE, path="string", rowCount=TRUE | FALSE, wildEscape="string", wildignore=TRUE | FALSE, wildsensitive=TRUE | FALSE;
Settings
ParameterDescription
allFilesWhen set to True, lists all file types in the results. When set to False, lists all file types that are supported by the data connector specified in the caslib.
caslibSpecifies the name of the caslib for the output table.
dataSourceOptionsSpecifies data source options (e.g., for ADLS, S3, Hadoop, etc.).
includeDirectoriesWhen set to True, includes directories in the results.
kbytesWhen set to True, lists file sizes in kilobytes.
pathSpecifies the file, directory, or table name. Supports wildcard characters (% and _) for pattern matching.
rowCountWhen set to True, includes the number of rows in the results. Not supported by all data sources.
wildEscapeSpecifies the character or characters to use for escaping wildcard characters.
wildignoreWhen set to True, the characters % and _ are not interpreted as wildcard characters.
wildsensitiveWhen set to False and wildcards are used, names are matched without regard to case.
Data Preparation View data prep sheet
Create Sample Data File

Loads the SASHELP.CARS dataset into CAS and saves it as a CSV file in the active caslib (Casuser) to ensure a file exists for listing.

Copied!
1 
2DATA casuser.cars;
3SET sashelp.cars;
4 
5RUN;
6 
7PROC CAS;
8TABLE.save / TABLE={name="cars", caslib="casuser"} name="cars.csv" caslib="casuser" replace=true;
9 
10RUN;
11 

Examples

Retrieves a list of all files available in the active caslib (typically Casuser).

SAS® / CAS Code Code awaiting community validation
Copied!
1PROC CAS; TABLE.fileInfo / caslib="casuser"; RUN;
Result :
A results table displaying the Name, Permission, Owner, Group, Size, and Time for each file in the caslib.

Lists only files with the '.csv' extension (case-insensitive), displays their size in kilobytes instead of bytes, and calculates the number of rows in each file.

SAS® / CAS Code Code awaiting community validation
Copied!
1 
2PROC CAS;
3TABLE.fileInfo / caslib="casuser" path="%.csv" kbytes=true rowCount=true wildSensitive=false;
4 
5RUN;
6 
Result :
A filtered results table showing only CSV files, with sizes in KB and a column indicating the row count for each file.

FAQ

What is the primary function of the fileInfo action?
How can I view all files in a caslib, including those not natively supported by the data connector?
Which parameter allows me to filter the results to a specific file or pattern?
How can I include the number of rows for each table in the output?
Is it possible to display file sizes in kilobytes?
Does the fileInfo action include directories in the output by default?
How do I perform a case-insensitive search when using wildcards in the 'path' parameter?
How can I search for file names containing actual '%' or '_' characters without treating them as wildcards?
How do I provide specific connection parameters for data sources like Hadoop or Oracle?
What parameter is used to specify the target caslib for the action?