我们如何在sas中的oscmd命令中传递变量
How can we pass variable in oscmd command in sas
我正在使用 oscmd 命令 运行 来自 sas 的一些操作系统操作,但想通过在 oscmd 命令中传递变量来使其通用。
我正在使用以下代码:
%global name =skstar; filename oscmd pipe "python test.py --inputvar=&name.";
命令中变量'name'的值没有被替换
编辑:上面的部分现在可以工作了,它只是一个引用错误。但想知道中止 oscmd cli 命令的方法,如果传递的参数值错误
也许你的数据步是错误的,但你没有写在那里。工作正常:
%let name=test words;
filename oscmd pipe "echo &name.";
data _null_;
infile oscmd;
input;
put _infile_;
run;
/*log:
NOTE: The infile OSCMD is:
Unnamed Pipe Access Device,
PROCESS=echo test words,RECFM=V,LRECL=32767
test words
NOTE: 1 record was read from the infile OSCMD.
The minimum record length was 10.
The maximum record length was 10.
NOTE: DATA statement used (Total process time):
real time 0.18 seconds
cpu time 0.03 seconds
*/
我正在使用 oscmd 命令 运行 来自 sas 的一些操作系统操作,但想通过在 oscmd 命令中传递变量来使其通用。
我正在使用以下代码:
%global name =skstar; filename oscmd pipe "python test.py --inputvar=&name.";
命令中变量'name'的值没有被替换
编辑:上面的部分现在可以工作了,它只是一个引用错误。但想知道中止 oscmd cli 命令的方法,如果传递的参数值错误
也许你的数据步是错误的,但你没有写在那里。工作正常:
%let name=test words;
filename oscmd pipe "echo &name.";
data _null_;
infile oscmd;
input;
put _infile_;
run;
/*log:
NOTE: The infile OSCMD is:
Unnamed Pipe Access Device,
PROCESS=echo test words,RECFM=V,LRECL=32767
test words
NOTE: 1 record was read from the infile OSCMD.
The minimum record length was 10.
The maximum record length was 10.
NOTE: DATA statement used (Total process time):
real time 0.18 seconds
cpu time 0.03 seconds
*/