Create a data set with the information on the files stored in a directory, selecting files by their extension
This example creates a data set in which each record refers about the information of each file stored in a directory (in the example the directory is "c:\mydocuments").
In particular it will be possible to select the files considering their extension/s; in the first example all the *.pdf files will be selected; in the second the *.pdf and the *.doc will be considered.
In order to run this example just paste the following statements in the Command area and press the button: EXECUTE. To view the content of the resulting data set go in the PATH tab and refer to the ones named Dircontent.
Note that in the second script it is executed a data step that considers just some values of the variable named FILEEXT; this because the filter in the PROC DIRLIST can be applied to just one type of extension (i.e. PDF).
This example creates a data set in which each record refers about the information of each file stored in a directory (in the example the directory is "c:\mydocuments").
In particular it will be possible to select the files considering their extension/s; in the first example all the *.pdf files will be selected; in the second the *.pdf and the *.doc will be considered.
In order to run this example just paste the following statements in the Command area and press the button: EXECUTE. To view the content of the resulting data set go in the PATH tab and refer to the ones named Dircontent.
Proc Dirlist out=dircontent; directory c:\mydocuments; nosubdir; filter pdf; run; |
Proc Dirlist out=dircontent; directory c:\mydocuments; nosubdir; run; dataset dict=dircontent out=dircontent; if (fileext.equalsIgnoreCase("pdf") || fileext.equalsIgnoreCase("doc")) output; run; |