SUPPORT / SAMPLES & SAS NOTES
 

Support

Sample 45805: List all files within a directory including sub-directories

DetailsCodeAboutRate It

The macro contained on the Full Code tab lists all of the files that contain a particular extension within a directory and all sub-directories. This macro can be modified to do more than just list the files. The %PUT can be replaced with other code to be used on each file. For example, if you want to %INCLUDE each file contained within these directories, you can do this easily by replacing the %PUT statement with the following:

   %include "&dir\&name" /source2;

For a quick and easy way to just LIST the files, the following can be used instead of the macro:

   Filename filelist pipe "dir /b /s c:\temp\*.sas"; 
                                                                                   
   Data _null_;                                        
     Infile filelist truncover;
     Input filename $100.;
     Put filename=;
   Run; 



These sample files and code examples are provided by SAS Institute Inc. "as is" without warranty of any kind, either express or implied, including but not limited to the implied warranties of merchantability and fitness for a particular purpose. Recipients acknowledge and agree that SAS Institute shall not be liable for any damages whatsoever arising out of their use of this material. In addition, SAS Institute will provide no support for the materials contained herein.