【问题标题】:infile statement doesn't work in batch mode SASinfile 语句在批处理模式 SAS 中不起作用
【发布时间】:2015-05-06 09:34:57
【问题描述】:

我的 SAS 基础 ETL 程序有一个奇怪的问题。该程序在 SAS base 的程序编辑器中运行良好,但在批处理模式下中止。我目前正在调试整个代码,我遇到了以下问题。我正在使用 infile 语句从某个位置读取 txt 文件。

当我在程序编辑器模式下运行程序时,infile 语句运行完美,数据集读取了适量的数据。但是当程序以批处理模式运行时,似乎 infile 语句被完全忽略了。数据集没有读取任何内容,并且保持为空,观察值为 0。

这是带有日志的代码:

DATA odd.mailables_&monthcode.;
length id_account 8
       language_id $2
       zip $4;
infile &file_name. delimiter='09'x firstobs=2 dsd pad missover end=last; 
load_date_time=datetime();
if _n_=1 then
  do;
    call symputx ('start_load_date_time', load_date_time);
  end; 
format load_date_time datetime20.;
monthcode="&monthcode.";
input id_account
      language_id $
      zip $;
if last then
  do;
    call symputx ('end_load_date_time', load_date_time);
  end;
RUN;

proc sort data=odd.mailables_&monthcode.;
by id_account;
run;  

这是之后的日志:

SYMBOLGEN:  Macro variable FILE_NAME resolves to "D:\mailables.txt"
"D:\mailables.txt"
SYMBOLGEN:  Macro variable MONTHCODE resolves to 20150506
SYMBOLGEN:  Macro variable FILE_NAME resolves to "D:\mailables.txt"
SYMBOLGEN:  Macro variable MONTHCODE resolves to 20150506

NOTE: The data set ODD.MAILABLES_20150506 has 0 observations and 5 variables.
NOTE: DATA statement used (Total process time):
      real time           0.01 seconds
      user cpu time       0.00 seconds
      system cpu time     0.00 seconds
      Memory                            141k
      OS Memory                         7864k
      Timestamp            8/05/2015  14:32:50


SYMBOLGEN:  Macro variable MONTHCODE resolves to 20150506

NOTE: PROCEDURE SORT used (Total process time):
      real time           0.00 seconds
      user cpu time       0.00 seconds
      system cpu time     0.00 seconds
      Memory                            33k
      OS Memory                         7864k
      Timestamp            8/05/2015  14:32:50

批处理模式和程序编辑器模式在读取代码的方式或您需要使用的语法方面有区别吗?

感谢您的信息

【问题讨论】:

  • 您遇到的错误是什么?
  • 我没有收到任何错误,他只是没有读取外部文件的内容。数据集有 0 个观测值。但我认为这与以下事情有关:[link]support.sas.com/kb/15/883.html
  • 他仍然完全忽略了数据步骤中的infile语句。我尝试使用路径定义文件名并将其用作 infile 的输入。但还是没有结果。太奇怪了,它在程序编辑器模式下就像一个魅力,而不是在批处理模式下。有什么区别:s
  • “增强”编辑器和批处理模式之间的一个区别是最大行长度。批处理模式将截断 256(或可能 512)个字符,而程序编辑器可能不会。如果你有一个很长的文件路径+名称,它可能是相关的。
  • 确实,我不得不从我的基于 SAS 存储过程服务器的网站请求用户使用较短的路径名来上传文件。

标签: sas etl


【解决方案1】:

标准的调试技术是将代码减少到可能仍会导致错误的最简单的部分。尝试运行它,看看 Program Editor 和批处理之间的输出是否存在差异。

data _null_;
  infile 'D:\mailables.txt';
  input;
  put _infile_;
run;

(对不起,只能回答,不能评论。)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2023-03-20
    • 2021-12-28
    • 1970-01-01
    • 2017-02-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多