%macro nowpath;
%global fullpath nowpath; /*定义为global,为后续调用准备*/
proc sql noprint;
select xpath into : fullpath /*选取全路径*/
from dictionary.extfiles /*dictionary.extfiles包含SAS路径信息*/
where substr(fileref,4) eq
(select max(substr(fileref,4)) /*max()保证选取最新(当前)路劲*/
from dictionary.extfiles
where substr(fileref,1,1) eq "#" and index(xpath,".sas") gt 0 );
quit;
/*选取当前路径*/
%let nowpath=%substr(&fullpath,1,%eval(%length(&fullpath)-%length(%scan(&fullpath,-1,\))));
%put The Full Path is: &fullpath;
%put The Now Path is: &nowpath;
%mend nowpath;
%nowpath;