Published on :
Utility CREATION_INTERNE

Macro lsfp2ds

This code is also available in: Deutsch Español Français
This SAS© macro, `lsfp2ds`, is designed to list Unix/Linux file names with their full paths and save them to a SAS© dataset. It accepts a positional parameter, `filepattern`, which specifies the file pattern to search for. An optional second positional parameter, `dsout`, allows defining the output dataset name; if omitted, it defaults to `_lsfp2ds`.
The resulting dataset will contain two variables: 'filename', which stores the full file path, and 'lcfname', a lowercase version of the file name (without the path prefix), useful for verifications. The `lsfp2ds` macro is a wrapper that internally calls the `%lsfp2sas©` macro to perform the main logic.
Data Analysis

Type : CREATION_INTERNE


The macro generates a SAS dataset whose content is derived from file system metadata (list of Unix/Linux files) rather than from a direct read of a pre-existing external dataset. The data is dynamically constructed within SAS from operating system information.

1 Code Block
MESSAGE LOG
Explanation :
This block writes an informational message to the SAS log, indicating the call of the 'lsfp2ds' macro with its version. This is a common practice for debugging and execution tracking.
Copied!
1%put MACRO CALLED: lsfp2ds v1.0;
2 Code Block
MACRO DEFINITION
Explanation :
This block defines the `lsfp2ds` macro. It manages the output dataset name by assigning `_lsfp2ds` by default if the `dsout` parameter is not provided. The main task of listing files and creating the dataset is delegated to another macro, `%lsfp2sas`, which is called with the `filepattern` and the finalized `dsout` parameters.
Copied!
1%macro lsfp2ds(filepattern,dsout);
2 %IF not %LENGTH(&dsout) %THEN %let dsout=_lsfp2ds;
3 %lsfp2sas(&filepattern,&dsout)
4%mend lsfp2ds;
This material is provided "as is" by We Are Cas. There are no warranties, expressed or implied, as to merchantability or fitness for a particular purpose regarding the materials or code contained herein. We Are Cas is not responsible for errors in this material as it now exists or will exist, nor does We Are Cas provide technical support for it.
Copyright Info : This is public domain software. No guarantee as to suitability or accuracy is given or implied. User uses this code entirely at their own risk.