2
votes

I have a strange problem with my SAS base ETL program. The program runs perfectly fine in the program editor of SAS base, but it aborts in batch mode. I'm currently debugging the entire code and I came at the following problem. I'm using an infile statement to read a txt file from a certain location.

When I run the program in the program editor mode, the infile statement runs perfectly and the dataset reads the right amount of data. But when the program runs in the batch mode, it seems like the infile statement is completely ignored. The datasets reads nothing and remains empty with 0 observations.

Here is the code with the log:

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;  

This is the log afterwards:

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

Is there a difference between the batch mode and the program editor mode in the way it reads the code or in the syntax you need to use?

Thanks for the information

1
What is the error that you are getting? - in_user
I don't get any error, he just doesn't read the content of the external file. The dataset has 0 observations. But I think it has something to do with the following thing: [link]support.sas.com/kb/15/883.html - user3411273
He still ignores the infile statement in the data step completely. I tried to define a filename with the path and use this as input for the infile. But still no result. It's so strange that it works like a charm in program editor mode and not in batch mode. What is the difference :s - user3411273
One difference between the "Enhanced" editor and batch mode is maximum line length. Batch mode will truncate at 256 (or maybe 512) characters while the program editor may not. If you've got a really long file path+name, it could be related. - Jeff
Indeed, I had to request users from my SAS stored process server based website to use shorter path names for their files to upload. - Dirk Horsten

1 Answers

0
votes

A standard debugging technique is to reduce the code to the smallest simplest piece possible which still causes an error. Try running this, and see if there's a difference in output between Program Editor and batch.

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

(Sorry, only allowed to answer, not comment.)