rbrt
rbrt

Reputation: 29

sas unix dirlist - how to read in file and last modified timestamp in yyyymmmdd:hh:ss format

I am using the following code in UNIX SAS to try and read in the files from a folder:

filename DIRLIST pipe 'dir "&path." ls -lt';

data dirlist ;
  length file $1000 ;
  infile dirlist length=reclen ;
  input file $varying256. reclen ;
  if index(file, '.txt')>=1;
run;

I do indeed manage to read in the files I need but the timestamp looks a little odd:

rw-r--r--. 1 user      8252 Oct 28 12:18 spec.txt

Is it possible to get the timestamp in a yyyymmmdd hh:ss format or similar?

thanks

Upvotes: 0

Views: 1157

Answers (1)

mpez0
mpez0

Reputation: 2883

The --full-time option to ls provides an ISO style date/time. It's not exactly what you ask, but "YYYY-MM-DD HH:MM:SS.ssssssss" fits the "or similar" part of your comment.

Depending on your platform, --full-option may not be available, but it seems it's part of standard linux distributions.

Upvotes: 1

Related Questions