tip00411

/*** 
    Macro: getFilePathname
    Author: Charles Patridge
    Purpose: Get the full file path name within a UNIX environment when issuing 
             an ls -lt > filelist.txt and reading the filelist.txt into a 
             SAS program and trying to get the filepathname.
***/
             
%macro getFilePathname( _string_ );
  %global filepathname;
     data _null_;
       if 0 ne index("&_string_",'/') then do;
         lastword = scan( "&_string_", -1, '/' );
         filepathname = substr( "&_string_", 1, index( "&_string_", trim(lastword)) + -1 );
       end;
       else filepathname = ' ';
       call symput('filepathname', trim(filepathname));
     run;
%mend;

/*** example call and use of getFilePathname ***/
/***
     %let mystring = /export/patridge/saspgms/myexcel.sas;
     %getFilePathname( &mystring );
     
     %put &filepathname;
     /export/patridge/saspgms/
***/  
/*** end of TIP 00411 ***/