From: Norman Weston on
I am reading in a text file that is basically an "ls -l" of a given
directory. The intent is to extract a given directory name (that just
happens to be a date). The problem is that several people use this
application and each one has a different format. What I need is a code
method of extracting the directory name (usually at the end of the string)
and converting it into a macro variable.

Here is an example of the data that I have:

8 drwxrwx--- 2 opid1 litsup 4096 Jan 13 2007 aug2005/
8 drwxrwxr-x 2 opid1 acis 4096 Jan 22 2009 aug2006/
8 drwxrwxr-x 2 opid1 acis 4096 Jan 22 2009 aug2007/
8 drwxrwxr-x 2 opid2 sas 4096 Apr 26 2006 aug2008/
8 drwxrwxr-x 2 opid3 sas 4096 Apr 26 2006 aug2009/
8 drwxrwxr-x 2 opid4 sas 4096 Dec 5 2006 dec2005/
8 drwxrwxr-x 2 opid3 sas 4096 Oct 26 2007 dec2006/
8 drwxrwxr-x 2 opid2 sas 4096 Oct 7 2008 dec2007/
8 drwxrwxr-x 2 opid1 sas 4096 Oct 6 13:41 dec2008/

The outputs from the above need to be in order:

aug2005
aug2006
aug2007
aug2008
aug2009
dec2005
dec2006
dec2007
dec2008

Obviously this is a sample data but the output could be any date 2005 -
current. And I am looking for that trend to continue.

Once I can extract the string from the input variable I can convert into a
macro variable myself. What I have currently is:


x "ls -l /directory/sub/file*.txt >! ~/uplift.txt";
run;

filename edxfiles '~/uplift.txt';

data x(keep=date);
format file_detail $char120.;
infile edxfiles dsd missover;
input;
file_detail = compress(_infile_);
datepos=index(file_detail,"txt")-9;
date=substr(file_detail,datepos,8);
if ^missing(date) then output;
run;

which works for some users but not all. Any assistance would be greatly
appreciated.