I'm uses SAS 9.3.
I have a macro that concatenates some SAS datasets and exports the new file into Access.
If the concatenation and export is successful, I then manually delete the source file; for they are redundant to concatenation.
Libname Library "&WorkPath";
%Let ACCESS_Name = WGRR1701_TShell_MAIN_MODASA6_Output;
%MergeOP(Suffix=
_1 _2 _3 ,
TabVol=Yes,
Briefing=No,
__OUTACCESSDS = &ACCESS_Name,
__OutPath=&WorkPath );
The log looks like this:
323 %MergeOP(Suffix=
324 _1 _2 _3 ,
325
326 TabVol=Yes,
327 Briefing=No,
328 __OUTACCESSDS = &ACCESS_Name,
329 __OutPath=&WorkPath );
MPRINT(MERGEOP): Data Library.TabVol;
MPRINT(MERGEOP): set Library.TabVol_1 Library.TabVol_2 Library.TabVol_3 ;
MPRINT(MERGEOP): run;
NOTE: There were 7480 observations read from the data set LIBRARY.TABVOL_1.
NOTE: There were 6325 observations read from the data set LIBRARY.TABVOL_2.
NOTE: There were 5445 observations read from the data set LIBRARY.TABVOL_3.
NOTE: The data set LIBRARY.TABVOL has 19250 observations and 78 variables.
NOTE: DATA statement used (Total process time):
real time 0.49 seconds
cpu time 0.48 seconds
MPRINT(MERGEOP): proc export data = Library.TabVol OUTTABLE= "TabVol" DBMS=ACCESSCS REPLACE ;
MPRINT(MERGEOP): AACC;
MPRINT(MERGEOP): DATABASE="F:\surveys\WGRR\WGRR1701\6-Tabs\6_MAIN_SA6\ModASA6\WGRR1701_TShell_MAIN_MODASA6_Output.mdb" ;
MPRINT(MERGEOP): DBDSOPTS="INSERTBUFF=25 DBCOMMIT=0";
MPRINT(MERGEOP): run ;
NOTE: "TabVol" table was successfully created.
NOTE: PROCEDURE EXPORT used (Total process time):
real time 17.12 seconds
cpu time 0.51 seconds
I would like to programmatically test if the export was "successful." If "successful," then I would add new section to the macro to delete the base files. In this example, the base files are TabVol_1, TabVol_2 and TabVol_3.
In my organization, we batch submit to process all macros. I had found some code that would read in the .log file and scan the .log for key words. I can only get that to work with in interactive mode; not with in batch.
data log_test;
infile "F:\SAM2\Versions_of_SAM\SAM2_20171128\log_check_test.log" truncover;
input a_line $256.;
if index(a_line, "ERROR:") > 0
then abort cancel;
run;
Maybe you can check for a non-zero value in the SYSCC or SYSERR automatic macro variables?
Vince DelGobbo
SAS R&D
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!
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.