确定 SAS 源文件的文件夹

发布于 2024-09-04 02:32:50 字数 519 浏览 2 评论 0原文

当我在企业指南中打开SAS文件并运行它时,它会在服务器上执行。源文件本身位于生产站点或开发站点。然而,在这两种情况下,它都是在同一服务器上执行的。我希望能够告诉我的脚本将结果存储在相对文件夹中。但是,如果我写类似的内容,

libname lib_out xport "..\tmp\foobar.xpt";

就会收到错误,因为 SAS Enterprise Guide 进程的工作文件夹不是我的源文件的位置,而是服务器上的文件夹。并且文件夹 ..\tmp 在那里不存在。即使可以,服务器进程也没有该文件夹的写入权限。

我想确定 .sas 文件是从哪个文件夹加载的,并相应地设置工作文件夹。 它是 S:\Development\myproject\sas\foobar.sas ,在另一种情况下,它是 S:\Production\myproject\sas\foobar.sas

在一种情况下, 有可能吗?或者你会怎么做?

When I open a SAS file in enterprise guide and run it, it is executed on the server. The source file itself is located either on the production site or the development site. In both cases, it is executed the same server however. I want to be able to tell my script to store results in a relative folder. But if I write something like

libname lib_out xport "..\tmp\foobar.xpt";

I get an error, because the working folder of the SAS Enterprise Guide process is not the location of my source file, but a folder on the server. And the folder ..\tmp does not exist there. Even if it would, the server process does not have write permission in that folder.

I would like to determine from which folder the .sas file was loaded and set the working folder accordingly. In one case it's S:\Development\myproject\sas\foobar.sas and in the other case it's S:\Production\myproject\sas\foobar.sas

It this possible at all? Or how would you do this?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

单身情人 2024-09-11 02:32:50

根据 EG 的配置方式,您也许能够使用 syshostname 全局宏变量之类的东西来确定保存结果的位置:

%macro sasdir;
    %global sasdir;
    %if "&syshostname" eq "mydevelopmenthost" %then %do;
      %let sasdir = S:\Development;
    %end;
    %else %if "&syshostname" eq "myproductionhost" %then %do;
      %let sasdir = S:\Production;
    %end;
%mend;
%sasdir;

libname lib_out xport "&sasdir\myproject\sas\tmp\foobar.xpt";

如果没有,请尝试查看其他哪些全局或自动宏变量可以通过执行以下操作来帮助您a:

%put _all_; 

希望这有帮助

干杯

Depending on the way EG is configured, you may be able to use something like the syshostname global macro variable to determine where to save your results:

%macro sasdir;
    %global sasdir;
    %if "&syshostname" eq "mydevelopmenthost" %then %do;
      %let sasdir = S:\Development;
    %end;
    %else %if "&syshostname" eq "myproductionhost" %then %do;
      %let sasdir = S:\Production;
    %end;
%mend;
%sasdir;

libname lib_out xport "&sasdir\myproject\sas\tmp\foobar.xpt";

If not, try looking at what other global or automatic macro variables may be able to help you by doing a:

%put _all_; 

Hope this helps

Cheers
Rob

孤凫 2024-09-11 02:32:50

好吧,这并不能准确回答你的问题,但我很容易获得这个宏,所以我想我会分享它。从这里您只需要进行一些字符串处理。

%macro progName;
%* Returns the name of current program;
    %let progPath = %sysfunc(GetOption(SysIn));
    %* if running in interactive mode, the above line will not work, and the next line should;
    %if  %length(&progPath) = 0 %then %let progPath = %sysget(SAS_ExecFilePath);

    %str(&progPath)
%mend progName;

OK, this isn't going to answer your question exactly, but I have this macro easily available so I thought I would share it. From here you would just need to do a little string processing.

%macro progName;
%* Returns the name of current program;
    %let progPath = %sysfunc(GetOption(SysIn));
    %* if running in interactive mode, the above line will not work, and the next line should;
    %if  %length(&progPath) = 0 %then %let progPath = %sysget(SAS_ExecFilePath);

    %str(&progPath)
%mend progName;
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文