DATA Step, Macro, Functions and more

DREAD Function: Sequence number of the member within the directory

Reply
Occasional Contributor FFR
Occasional Contributor
Posts: 6

DREAD Function: Sequence number of the member within the directory

What determines the sequence number of some file in some directory (UNIX)?

I wanted to use DREAD(&dir,1) to read the filename of the first file in the direcotry in alphabetical order, but it doesn't work since the sequence is not alphabetical and also not date or file size. But what is it then?

The documentation for the  DREAD function only says:

nval

is a numeric constant, variable, or expression that specifies the sequence number of the member within the directory.

I think there should be some information on what the sequence number actually is.

Regular Contributor
Posts: 227

Re: DREAD Function: Sequence number of the member within the directory

Here is a page with programs for making lists.

Making Lists - sasCommunity

make the list of filenames then sort by filename.

I have no idea where the nval value is assigned.

This is similar to the order of macro variables: makes no obvious sense.

Super User
Posts: 11,343

Re: DREAD Function: Sequence number of the member within the directory

Use Dnum for the number of members and loop over the value 1 to dnum to get the name for each numbered file in a data set. Then use that to get other characteristics, sort and process by the sorted order.

I don't know the Unix file system well enough but I suspect there is a reason for order. And which date did you look at? Was it a date updated, created, read, "touched" or something else?

Occasional Contributor FFR
Occasional Contributor
Posts: 6

Re: DREAD Function: Sequence number of the member within the directory

Thanks Ron and ballardw for the hints. Actually I solved my problem in a similiar way. I am just curios how DREAD works - also to use it as it is and not with some workaround.

Date was date updated and I just checked that it's not date created. As it really seems arbitrary my guess would be that it uses the order on the hard drive, i.e. the order in which files in the direcotry are read.

PS: Does someone know the guy who implemented this function? I guess he or she knows ;-)

Contributor
Posts: 65

Re: DREAD Function: Sequence number of the member within the directory

You can find the usage of Dread in this thread

Ask a Question
Discussion stats
  • 4 replies
  • 351 views
  • 0 likes
  • 4 in conversation