Published on :
Utility INTERNAL_CREATION

Create a SAS dataset from a list of Unix/Linux files

This code is also available in: Deutsch Español Français
Awaiting validation
Attention : This code requires administrator privileges.
This macro, `%ls2ds`, is a wrapper that uses another unprovided macro, `%ls2sas©`, to accomplish its task. It takes a file pattern (`filepattern`) and an output dataset name (`dsout`, by default '_ls2ds'). Its purpose is to capture a list of filenames from the file system (via the 'LS -1' command) and transform it into a SAS© dataset. The output dataset is expected to contain the variables 'filename' (filename as listed) and 'lcfname' (lowercase version for verification). Executing external system commands ('LS -1') generally implies administrative privileges or specific capabilities of the SAS© environment.
Data Analysis

Type : INTERNAL_CREATION


The output dataset is created internally by the macro from a list of files obtained directly from the Unix/Linux file system via the 'LS -1' command. The data does not come from pre-existing external SAS sources to the script, but is generated from operating system information.

1 Code Block
MACRO Data
Explanation :
This block defines the `%ls2ds` macro. It handles an optional `dsout` parameter, assigning it the default value `_ls2ds` if none is provided. It then calls the `%ls2sas` macro, which is supposed to contain the actual logic to query the file system and create the SAS dataset from the file pattern and output dataset name.
Copied!
1%put MACRO CALLED: ls2ds v1.0;
2 
3%macro ls2ds(filepattern,dsout);
4 %IF not %LENGTH(&dsout) %THEN %let dsout=_ls2ds;
5 %ls2sas(&filepattern,&dsout)
6%mend ls2ds;
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 software is in the public domain. No warranty as to its suitability or accuracy is given or implied. The user uses this code entirely at their own risk.