Published on :

File Listing via System Pipe (Windows)

This code is also available in: Deutsch Español Français
Awaiting validation
Attention : This code requires administrator privileges.
The script uses the FILENAME statement with the PIPE method to execute the 'dir' command (Windows-specific). It reads the output stream of this command into a DATA Step to create a SAS© table containing the file names. This code requires the activation of system commands (XCMD) and is specific to a Windows environment.
Data Analysis

Type : EXTERNE


The data is dynamically generated by the execution of the OS command 'dir /l/b c:\*.*'.

1 Code Block
DATA STEP Data
Explanation :
Configuration of a pipe to the system command 'dir' and reading the resulting text stream to create the 'figfile' table. Each line of the command's output becomes an observation.
Copied!
1filename files pipe 'dir /l/b c:\*.*' ;
2DATA figfile ;
3 INFILE files pad lrecl=128 ;
4 INPUT fname $128. ;
5RUN ;
2 Code Block
PROC PRINT
Explanation :
Display of the retrieved file list.
Copied!
1PROC PRINT ;
2RUN ;
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.