全部版块 我的主页
论坛 数据科学与人工智能 数据分析与数据科学 SAS专版
2368 4
2022-04-20
%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;

二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

全部回复
2022-4-20 21:48:18
full path 存储在环境变量sas_execfilepath中,直接获取环境变量的值会更方便些:
复制代码
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

2022-4-20 22:30:25
%let fullpath= %sysget(sas_execfilepath);
%let nowpath=%substr(&fullpath,1,%eval(%length(&fullpath)-%length(%scan(&fullpath,-1,\))));
%put The Full Path is: &fullpath;
%put The Now Path is: &nowpath;
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

2022-4-21 22:03:49
/* 改变工作路径 change the working directory to the current file folder. */
%macro cd_currfile_path;
        %let currfile_path = %qsubstr(%sysget(SAS_EXECFILEPATH), 1, %length(%sysget(SAS_EXECFILEPATH))-%length(%sysget(SAS_EXECFILEname)) );
        x "cd &currfile_path.";
%mend cd_currfile_path;
%cd_currfile_path;
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

2022-4-21 22:09:47
%sysexec md "../data" & exit;/*新建文件夹*/

libname dlglib '../data';
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

相关推荐
栏目导航
热门文章
推荐文章

说点什么

分享

扫码加好友,拉您进群
各岗位、行业、专业交流群