BookmarkSubscribeRSS Feed
Mike_B
Obsidian | Level 7

We have a bunch of ZIP file import programs that run via a scheduled task on a Windows server. These have been running fine for years. Recently, one or two files--always the same ones--fail to import. The issue seems to be that DREAD does not detect a file in the ZIP. There is always 1 file in the ZIP.

 

If we run the program manually, it works fine.

 

Step that fails:

filename inzip zip "&ziploc";

data contents(keep=memname);
length memname $8.;
fid=dopen("inzip");
memname=dread(fid,1);
output;
rc=dclose(fid);
call symputx('filename',memname);
run;

 

Log:

76         data contents(keep=memname);
77         length memname $8.;
78         fid=dopen("inzip");
79         memname=dread(fid,1);
80         output;
81         rc=dclose(fid);
82         call symputx('filename',memname);
83         run;

NOTE: Compression was disabled for data set WORK.CONTENTS because compression overhead would increase the size of the data set.
NOTE: List Handle Creation Failed.
NOTE: Argument 1 to function DREAD(0,1) at line 79 column 9 is invalid.
memname=  fid=0 rc=70021 _ERROR_=1 _N_=1
NOTE: The data set WORK.CONTENTS has 1 observations and 1 variables.
NOTE: DATA statement used (Total process time):
      real time           0.03 seconds
      cpu time            0.01 seconds

 

I haven't been able to find anything useful about this issue. Any help is appreciated.

 

8 REPLIES 8
LeonidBatkhan
Lapis Lazuli | Level 10

Hi Mike_B,

It seems that your macro variable &ziploc does not resolve correctly. Can you run your code with option

options symbolgen;

to see its value and make sure the file defined by that macro variable exists?

Mike_B
Obsidian | Level 7
My apologies. I omitted that part of the log. Symbolgen was on and the macro variable resolved to the correct file.

72 filename inzip
SYMBOLGEN: Macro variable ZIPLOC resolves to \\SERVERNAME\DIRECTORY\FILENAME.ZIP
72 ! zip "&ziploc";
73
LeonidBatkhan
Lapis Lazuli | Level 10

Can you try specifying the member name as well?

filename inzip zip "&ziploc" member="filename.extension";
Mike_B
Obsidian | Level 7

Leonid, unfortunately the name of the file inside the ZIP is unpredictable which is why we are using DREAD() to get the name and store it inside a macro variable which we can then use with an infile/inzip statement.

Tom
Super User Tom
Super User

Are you looking for a specific file in the ZIP? Or do you want to read everything that is there?

If the later just use member='*';

Example:

%let fname=%sysfunc(pathname(work))/test.zip;

data _null_;
  file "&fname" zip member='file1';
  put 'hello';
run;

data _null_;
  infile "&fname" zip member='*';
  input ;
  put _infile_;
run;

You will probably still get errors for the files you could not open before, but now your code is simpler.

Mike_B
Obsidian | Level 7
Tom, I will give the member='*' approach a try and see what happens. I am always game for simplifying a program.
Tom
Super User Tom
Super User

From your log it looks like the DOPEN() is failing since it returned 0 as the file id.

 

Most likely some issue with accessing the network file from that share name.

Are you SAS jobs always running on the same server? Same user?

 

Is there some type of back up service running at the same time that might lock the file and keep SAS from opening it?

Mike_B
Obsidian | Level 7

Tom

 

The scheduled task is always with the same user's credentials and on the same server. The file is on the same server as the scheduled task and SAS 9.4m7 install. There is a backup that occurs the same day the scheduled task runs, but I don't know when that happens.

 

I looked at the event log and saw 2 possible issues around the time the SAS program ran. However, these two events show up almost every day multiple times a day and don't seem to cause any noticeable problems the rest of the time, so I doubt they are related.

  1. Event 1530: some kind of "user handles leaked" issue involving sas.exe.
  2. Event 2003 - which says "event ID 2003 from source SASPERF cannot be found."

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 8 replies
  • 1959 views
  • 2 likes
  • 3 in conversation