SAS 9.1 Language Reference Dictionary, Volumes 1, 2 and 3
DREAD Function
Returns the name of a directory member
Category: External Files
Syntax
DREAD ( directory-id , nval )
Arguments
directory-id
-
specifies the identifier that was assigned when the directory was opened, generally by the DOPEN function.
-
Restriction: The directory must have been previously opened by using DOPEN.
nval
-
specifies the sequence number of the member within the directory.
Details
DREAD returns a blank if an error occurs (such as when nval is out-of-range). Use DNUM to determine the highest possible member number that can be passed to DREAD.
Examples
This example opens the directory identified by the fileref MYDIR, retrieves the number of members , and places the number in the variable MEMCOUNT. It then retrieves the name of the last member, places the name in the variable LSTNAME , and closes the directory:
%let filrf=mydir; %let rc=%sysfunc(filename(filrf, physical-name )); %let did=%sysfunc(dopen(&filrf)); %let lstname=; %let memcount=%sysfunc(dnum(&did)); %if &memcount > 0 %then %let lstname=%sysfunc(dread(&did,&memcount)); %let rc=%sysfunc(dclose(&did));
See Also
Functions:
-
'DNUM Function' on page 502
-
'DOPEN Function' on page 503