SAS Component Language Dictionary |
Returns the name of a directory member
name=DREAD(directory-id,member-num);
|
-
name
-
contains either the name of the member,
or a blank if an error occurs (for example, if nval
is out-of-range).
Type: Character
-
directory-id
-
contains the identifier that was
assigned when the directory was opened. If directory-id
is invalid, the program halts.
Type: Numeric
-
member-num
-
is the sequence number of the member
within the directory.
Type: Numeric
Use DNUM to determine the highest possible
member number that can be passed to DREAD. DREAD works only if the directory
was previously opened by the DOPEN function.
Open the directory identified by the fileref
MYDIR, retrieve the number of members and place the number in the variable
MEMCOUNT, retrieve the name of the last member and place the name in the variable
LSTNAME, and then close the directory:
/* Assign the fileref MYDIR to the */
/* filename stored in the variable DIRNAME */
/* and open it. */
rc=filename('mydir',dirname);
dirid=dopen('mydir')
lstname='';
memcount=dnum(dirid);
if (memcount>0) then
lstname=dread(dirid,memcount);
rc=dclose(dirid);
DNUM
DOPEN
Copyright © 2009 by SAS Institute Inc., Cary, NC, USA. All rights reserved.