PING
0.9
Statistical data handling and processing in production environment
|
Return the names of all files member of a given directory.
dir
: a directory full path;match
: (option) inclusion pattern for the name of the members (files and directories, also depending on parameter excldir
below) searched for; for instance, you may wish to list all files starting with "table_" passing
match=table_`; default: empty, no pattern is defined, the macro will search for all members without restriction;nomatch
: (option) exclusion pattern for the name of the members searched for; NOT IMPLEMENTED YET;ext
: (option) extension of the members searched for; default: no extension, the macro will search for all members without consideration for the extension;beg
: (option) boolean flag (yes/no
) set to force the matching of the match
string at the beginning of the filenames; default: beg=no
, i.e. a match with the match
string is looked for anywhere in the filenames whenever end=no
as well (see below);end
: (option) ibid with the end of the filenames; end
is incompatible with beg
(see above); default: end=no
, i.e. a match with the match
string is looked for anywhere in the filenames;casense
: (option) boolean flag (yes/no
) set to perform cases sensitive search/matching; default: casense=yes
, i.e. the pattern match
will be searched/matched exactly;excldir
: (option) boolean flag (yes/no
) set to exclude subdirectories from the search; default: excldir=no
, i.e. sub-directories, when they exist, are also searched for (and matched against all search criteria above);sep
: (option) output list separator; default: sep=%quote( )
, i.e. a blank separator is used.list
: list of the files member of the directory dir
matching the constraints on match
and/or ext
when passed as parameters.
let us test the current file (file_ls.sas
):
then running:
returns list=file_ls
, while running:
returns list=file_ls.sas
, and running:
returns in list
the list of all files present in the directory &G_PING_ROOTPATH/library/autoexec
. The options beg/end
can be further used to specified the type of matching, e.g.:
returns in list
the list of all files present in the directory &G_PING_ROOTPATH/library/autoexec
whose names start with the pattern list
; in particular the file list_quote
will be returned in list
, but not clist_unquote
will not.
Run macro %_example_file_ls
for more examples.
ext
, the macro automatically omits the extension in the output list
. Otherwise, the name of the files are provided with their extensions. Note that, contrary to %dir_ls
that works only on non-Windows machines, this macro runs on all platforms/systems.
beg=yes
and end=yes
, the macro looks for filenames matching exactly match
.Hamilton, J.(2012): "Obtaining a list of files in a directory using SAS functions".
%dir_ls, %dir_check, %file_name, FEXIST, FILENAME, DOPEN, DNUM, DREAD.