通过 SH 文件运行 SAS 批处理作业:SAS 脚本包含导出到 csv - 在哪里/如何获取输出? [英] Run SAS batch jobs via SH files: SAS script contains export to csv - where is / how to get the output?

查看:72
本文介绍了通过 SH 文件运行 SAS 批处理作业:SAS 脚本包含导出到 csv - 在哪里/如何获取输出?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

作为大学工作人员,我可以在 WRDS 上运行批处理作业.我按照说明操作,还创建了包装器并发送了作业.

As university staff, I am allowed to run batch jobs on WRDS. I followed the instructions, also created the wrapper and send the job.

#!/bin/bash
#$ -cwd
#$ -m abe
#$ -M myemail@email.com
echo "Starting Job at `date`"
sas my_sas_script.sas
echo "Ending Job at `date`"

我通过

qsub my_program.sh

这项工作完成得非常快(!).在我的主目录中,我得到了我的日志文件(o"和e"文件).

The job finished very quickly(!). In my home directory, I got my logfiles (the "o" and "e" files).

在我的 SAS 脚本中,我有一个导出到 CSV 的行,但是,我不能在任何地方.是不是因为 SAS 脚本没有成功运行?我是否必须调整代码(实际上它是来自这个问题的代码,但不是作为一个不起作用的宏而是作为一个简单的代码 SAS 数据步骤视图和数据包装在宏 for 循环中;我首先从我的库开始,然后继续代码).

In my SAS script I have an export to CSV line, however, I cannot it anywhere. Is it because the SAS script didn't run successfully? Do I have to adjust the code (In fact it's the code from this question, however not as a not-working macro but as a simple code SAS data step view and data wrap in a macro for loop; I first start with my libraries and then continue with the code).

我再次运行 my_program.sh 并得到以下日志(缩短);

edit: I run my_program.sh again and got the following log (shortened);

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"未定义.

It would appear that your SAS program is executing just fine, it just fails to finish due to syntax errors, namely (in the first instance) that the macro variable "STOCK" is undefined.

我建议首先在 SAS 的常规(干净)实例中运行该程序,并确保它完成时没有错误.

I suggest running the program first in a regular (clean) instance of SAS and make sure it completes without errors.

如果它在那里运行良好,但不是在 shell 批处理中,那么一定存在以下问题之一:

If it runs fine there, but not in shell batch, then there must be an issue with one of the following:

  • autoexec(确保您在批处理实例中运行相同的 autoexec)
  • config(检查正在使用的 sasv9.cfg 文件)
  • 用户权限(批处理帐户是否与成功"帐户相同/具有相同的权限?)

这篇关于通过 SH 文件运行 SAS 批处理作业:SAS 脚本包含导出到 csv - 在哪里/如何获取输出?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆