⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 getpath.sas

📁 缺失数据的利器
💻 SAS
字号:

%macro getpath;  /* macro to get the path name */

  %if (%bquote(&name) eq ) %then %let name = temp;  /* no name */
  %else %do;  /* name specified */
    %if (%qsubstr(&name, 1, 1) eq %str(%") or %qsubstr(&name, 1, 1) eq %str(%')) %then
      %let name = %qsubstr(&name, 2, %length(&name)-2);  /* remove quotes */
  %end;
  %if (%bquote(&dir) eq ) %then %let path = &name;  /* no directory */
  %else %if (%bquote(%upcase(&dir)) eq DEFAULT) %then %do;  /* default directory */
    %if (&sysscp eq WIN) %then %do;  /* Windows */
      %let dir = ;
      %if (&sysver ne 6.12) %then %let dir = %sysget(MYSASFILES);
      %if (%bquote(&dir) eq ) %then %let dir = %sysfunc(getoption(SASUSER));
      %if (%bquote(&dir) eq ) %then %let path = &name;  /* just name */
      %else %if (%qsubstr(&dir, %length(&dir)) eq %str(\)) %then
        %let path = &dir.&name;
      %else %let path = &dir\&name;  /* concatenate directory and name */
    %end;
    %else %do;  /* Unix */
      %let dir = %sysfunc(getoption(SASUSER));
      %if (%bquote(&dir) eq ) %then %let path = &name;  /* just name */
      %else %let path = &dir/&name;  /* concatenate directory and name */
    %end;
  %end;
  %else %do;  /* directory specified */
    %if (%qsubstr(&dir, 1, 1) eq %str(%") or %qsubstr(&dir, 1, 1) eq %str(%')) %then
      %let dir = %qsubstr(&dir, 2, %length(&dir)-2);  /* remove quotes */
    %if (&sysscp eq WIN) %then %do;  /* Windows */
      %if (%qsubstr(&dir, %length(&dir)) eq %str(\)) %then
        %let path = &dir.&name;
      %else %let path = &dir\&name;  /* concatenate directory and name */
    %end;
    %else %do;  /* Unix */
      %if (%qsubstr(&dir, %length(&dir)) eq %str(/)) %then
        %let path = &dir.&name;
      %else %let path = &dir/&name;  /* concatenate directory and name */
    %end;
  %end;

%mend getpath;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -