通过SH文件运行SAS批处理作业:SAS脚本包含导出到csv - 在哪里/如何获得输出?
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了通过SH文件运行SAS批处理作业:SAS脚本包含导出到csv - 在哪里/如何获得输出?相关的知识,希望对你有一定的参考价值。
作为大学的工作人员,我被允许在WRDS上运行批量工作。我按照说明操作,也创建了包装器并发送作业。
#!/bin/bash
#$ -cwd
#$ -m abe
#$ -M myemail@email.com
echo "Starting Job at `date`"
sas my_sas_script.sas
echo "Ending Job at `date`"
我通过调用shell脚本
qsub my_program.sh
工作很快完成(!)。在我的主目录中,我得到了我的日志文件(“o”和“e”文件)。
在我的SAS脚本中,我有一个导出到CSV行,但是,我不能在任何地方。是因为SAS脚本没有成功运行吗?我是否必须调整代码(实际上它是来自这个问题的代码,但不是作为一个不起作用的宏而是作为一个简单的代码SAS data step view and data wrap in a macro for loop;我首先从我的库开始然后继续代码)。
编辑:我再次运行my_program.sh并得到以下日志(缩短);
NOTE: Unable to open SASUSER.PROFILE. WORK.PROFILE will be opened instead.
NOTE: All profile changes will be lost at the end of the session.
.
.
.
35 data _v_&tables / view=_v_&tables;
36 set &taq_ds;
37 where symbol = &stock and
_
22
76
37 !
WARNING: Apparent symbolic reference STOCK not resolved.
ERROR 22-322: Syntax error, expecting one of the following: a name,
a quoted string, a numeric constant, a datetime constant,
a missing value, INPUT, PUT.
ERROR 76-322: Syntax error, statement will be ignored.
38 (time between '9:30:00't and '16:00:00't) and
39 mode = 12 and
40 EX = 'N';
ERROR: Syntax error while parsing WHERE clause.
41 run;
NOTE: The SAS System stopped processing this step because of errors.
NOTE: DATA statement used (Total process time):
real time 3.39 seconds
cpu time 0.73 seconds
46 data xtemp2;
47 set _v_&tables;
47 set _v_&tables;
___
180
ERROR 180-322: Statement is not valid or it is used out of proper order.
48 by symbol date time;
__
180
ERROR 180-322: Statement is not valid or it is used out of proper order.
49 format itime rtime time12.;
______
180
ERROR 180-322: Statement is not valid or it is used out of proper order.
50 if first.symbol = 1 or first.date = 1 then do;
__
180
ERROR 180-322: Statement is not valid or it is used out of proper order.
51
54 rtime = time;
_____
180
ERROR 180-322: Statement is not valid or it is used out of proper order.
55 iprice = bid;
______
180
ERROR 180-322: Statement is not valid or it is used out of proper order.
56 oprice = ofr;
______
180
ERROR 180-322: Statement is not valid or it is used out of proper order.
57 itime = &start_time;
_____
180
ERROR 180-322: Statement is not valid or it is used out of proper order.
58 end;
___
180
ERROR 180-322: Statement is not valid or it is used out of proper order.
59
60 if time >= itime then do;
__
180
ERROR 180-322: Statement is not valid or it is used out of proper order.
61 output;
______
180
ERROR 180-322: Statement is not valid or it is used out of proper order.
62 itime = itime + &interval_seconds;
_____
180
ERROR 180-322: Statement is not valid or it is used out of proper order.
63 do while(time >= itime);
__
180
ERROR 180-322: Statement is not valid or it is used out of proper order.
64 output;
______
180
ERROR 180-322: Statement is not valid or it is used out of proper order.
65 itime = itime + &interval_seconds;
_____
180
ERROR 180-322: Statement is not valid or it is used out of proper order.
66 end;
___
180
ERROR 180-322: Statement is not valid or it is used out of proper order.
67 end;
___
180
ERROR 180-322: Statement is not valid or it is used out of proper order.
68 rtime = time;
_____
180
ERROR 180-322: Statement is not valid or it is used out of proper order.
69 iprice = bid;
______
180
ERROR 180-322: Statement is not valid or it is used out of proper order.
70 oprice = ofr;
______
180
ERROR 180-322: Statement is not valid or it is used out of proper order.
71 retain itime iprice oprice;
______
180
ERROR 180-322: Statement is not valid or it is used out of proper order.
73 run;
74
75 Title "Final output -- 1min interval";
76 proc print data=work.xtemp2 (obs=100);
ERROR: File WORK.XTEMP2.DATA does not exist.
77 var symbol date itime iprice oprice;
ERROR: No data set open to look up variables.
ERROR: No data set open to look up variables.
ERROR: No data set open to look up variables.
ERROR: No data set open to look up variables.
ERROR: No data set open to look up variables.
78 run;
NOTE: The SAS System stopped processing this step because of errors.
NOTE: SAS set option OBS=0 and will continue to check statements.
This might cause NOTE: No observations in data set.
NOTE: PROCEDURE PRINT used (Total process time):
real time 0.00 seconds
cpu time 0.00 seconds
NOTE: PROCEDURE EXPORT used (Total process time):
real time 0.00 seconds
cpu time 0.00 seconds
WARNING: Apparent symbolic reference STOCK not resolved.
NOTE: The SAS System stopped processing this step because of errors.
81 proc export data=work.xtemp2 outfile="/home/Output/
81 ! &filename" dbms=csv;
82 run;
83
84 DM 'log; file "/home/Logs/ &filename.log" replace';
WARNING: Apparent symbolic reference STOCKLOG not resolved.
84 !
85 DM "log; clear; ";
ERROR: Errors printed on page 2.
答案
看起来您的SAS程序执行得很好,由于语法错误而无法完成,即(在第一个实例中)宏变量“STOCK”未定义。
我建议首先在常规(干净)SAS实例中运行程序,并确保它完成没有错误。
如果它在那里运行正常,但不是在shell批处理中运行,则必须存在以下某个问题:
- autoexec(确保在批处理实例中运行相同的autoexec)
- config(检查正在使用的sasv9.cfg文件)
- 用户权限(批处理帐户是同一帐户/具有与“成功”帐户相同的权限吗?)
以上是关于通过SH文件运行SAS批处理作业:SAS脚本包含导出到csv - 在哪里/如何获得输出?的主要内容,如果未能解决你的问题,请参考以下文章