I've a code like below and it seems to be running as excepted. However, I could see a error message in SAS log for some reasons which I could not figure out.
data log.output_file ;
infile "&path/output_file.txt" firstobs=2 truncover ;
input fname $400. ;
run;
%macro sas_log_analysis;
data log.log_analysis;
set log.output_file;
filename=fname;
length fname $400;
infile dummy dsd truncover FILEVAR = fname END = end_of_file LRECL=32000;
DO WHILE (not end_of_file);
input var : $ 3000.;
/*filename=fname;*/
var1 = _infile_;
if var1 = :'201' then do;
Date_TimeStamp= scan(var1,1," ");
output;
end;
end;
%mend sas_log_analysis;
%macro java_log_analysis;
data java;
set sashelp.class;
run;
%mend java_log_analysis;
%macro dotnet_log_analysis;
data dotnet;
set sashelp.class;
run;
%mend dotnet_log_analysis;
data _null_;
set log.output_file;
if fname =: '/usr/sas/sas_config/Lev1/SASApp/StoredProcessServer/Logs/SASApp_STPServer' then call execute ('%sas_log_analysis;');
else if fname =: '/usr/sas/tir/test/loganalysis/temp_java' then call execute ('%java_log_analysis;');
else if fname =: '/usr/sas/tir/test/loganalysis/temp_dotnet' then call execute ('%dotnet_log_analysis;');
else put 'no log files';
run;
data _null_;
set log.output_file;
if fname =: '/usr/sas/sas_config/Lev1/SASApp/StoredProcessServer/Logs/SASApp_STPServer' then call execute ('%sas_log_analysis;');
else if fname =: '/usr/sas/tir/test/loganalysis/temp_java' then call execute ('%java_log_analysis;');
else if fname =: '/usr/sas/tir/test/loganalysis/temp_dotnet' then call execute ('%dotnet_log_analysis;');
else put 'no log files';
run;
Log.output_file has records like follows.
fname
/usr/sas/sas_config/Lev1/SASApp/StoredProcessServer/Logs/SASApp_STPServer_2015-10-04_19142.log
/usr/sas/tir/test/loganalysis/temp_java.log
/usr/sas/tir/test/loganalysis/temp_dotnet.log
For testing purpose, I've created a empty log files as temp_java.log and temp_dotnet.log. Could someone tell me that these two empty log files are root cause for the error?
NOTE: There were 5472 observations read from the data set LOG.LOG_ANALYSIS.
NOTE: The data set WORK.LOG_TABLE_FINAL has 5472 observations and 7 variables.
NOTE: The PROCEDURE REPORT printed pages 1-406.
NOTE: PROCEDURE REPORT used (Total process time):
real time 5.47 seconds
cpu time 5.43 seconds
13 + close; ods listing; ods listing close;;
14 + data java; set sashelp.class; run;
NOTE: There were 19 observations read from the data set SASHELP.CLASS.
12 The SAS System 06:17 Monday, October 5, 2015
NOTE: The data set WORK.JAVA has 19 observations and 5 variables.
NOTE: DATA statement used (Total process time):
real time 0.00 seconds
cpu time 0.00 seconds
14 + ;
15 + data dotnet; set sashelp.class; run;
NOTE: There were 19 observations read from the data set SASHELP.CLASS.
NOTE: The data set WORK.DOTNET has 19 observations and 5 variables.
NOTE: DATA statement used (Total process time):
real time 0.00 seconds
cpu time 0.00 seconds
15 + ;
267
ERROR: Errors printed on page 6.
You need to expand the "plus" as else you're hiding the relevant parts of the log.
As for the code you've posted: I can run it without errors as long as the files listed in "output_files.txt" files exist.
Available on demand!
Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.
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.