I am using exactly this type of macro:
%MACRO EXPORT_TABLE(table, database, name);
PROC EXPORT
DATA = WORK.&table.
OUTTABLE = "&name."
DBMS = ACCESS REPLACE;
DATABASE = &database.;
RUN;
%MEND;
%EXPORT_TABLE(Somename, "path.mdb", Anothername);
However, if the file already exists, SAS doesn't replace it, but makes the file bigger in size (number of rows/cols are preserved, but size of the file is higher). You can imagine how many problems this causes.
Is there any way, how to deal with this? I have tried NEWFILE = yes;, but it doesn't work with access databases.
Thank you
Hi, thank you for reply. Could you be more specific about dropping the table? Access is first time referenced in the macro. Thanks
Unfortunately, this doesn't work. I implemented it into the macro in this way:
%MACRO EXPORT_TABLE(table, database, name);
LIBNAME ACC &database.;
PROC DATASETS LIB = ACC NOPRINT;
DELETE &name.;
QUIT;
PROC EXPORT
DATA = WORK.&table.
OUTTABLE = "&name."
DBMS = ACCESS REPLACE;
DATABASE = &database.;
RUN;
%MEND;
%EXPORT_TABLE(Somename, "path.mdb", Anothername);
Log says that the libname was successfully assigned, also 'Deleting ACC.tablename"... but still, the file size is increasing.
Edit:
When using with DIRECT_EXE and PROC SQL:
LIBNAME ACC &database. DIRECT_EXE = DELETE;
PROC SQL; DELETE FROM ACC.&name.; QUIT;
LIBNAME ACC CLEAR;
It seems like working. The table itself is not deleted but just cleared (ie it is empty). However, the size doesn't apparently change.
Thank you for the solution.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.
Find more tutorials on the SAS Users YouTube channel.