BookmarkSubscribeRSS Feed
deleted_user
Not applicable
On a Windows XP_PRO platform, I have a batch SAS program (v9.1.3) using a libname statement to read 600+ Access databases. I use a macro to read a table in each database and append the selected records to a SAS dataset for further processing. I've noticed that occasionally no records are selected from the Access table, which creates an empty temporary SAS dataset. Somehow, when there are no records selected, it looks as though that last Access database is kept open, even though subsequent databases are read and processed by the macro. This SAS program begins by using x statements to use a WinZip utility to unzip the archive where the Access databases are stored and write the databases into a folder, and at the end of the SAS statements in my program I use the x statements again to delete the .mdb files and the folders. My problem is that because the last .mdb file that had 0 records selected for processing within my program is still considered to be in use, my x statement won't delete that file. I end up having to manually delete the .mdb file. Is there code that I can incorporate into my SAS program to close the .mdb file?
1 REPLY 1
deleted_user
Not applicable
I don't have an Access database I can test this with, and in any case there is no guarantee I will have the same problem. However, I would suggest that if you are creating references to files that you will then manipulate through the operating system, then you should release the SAS connection to them first.

Whether it is a library reference or a file reference, the key word Clear will release the handle and may overcome your problem. Otherwise you may be in danger of memory leak or other OS problems because you have unused handles open on your session.

Libname ACCESSLIB Clear;

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

Discussion stats
  • 1 reply
  • 976 views
  • 0 likes
  • 1 in conversation