DATA Step, Macro, Functions and more

If else call execute

Reply
Super Contributor
Posts: 436

If else call execute

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.
PROC Star
Posts: 1,322

Re: If else call execute

Hi, it looks like you have cut out the key portion of your log (log line 16 through 266 are missing). If you would at those lines, you should see an ERROR: message. If you need help understanding the message, please post that section of the log.
Super Contributor
Posts: 436

Re: If else call execute

I did not missed anything between the lines16 to 276 as I copy/paste it from log window. Nothing in between the line 15 and 265. I don't see any error before that.
PROC Star
Posts: 1,322

Re: If else call execute

Well, then I'm flummoxed. You mean the log skips from line 15 to line 267? Are you submitting this code via EG? If so, suggest you turn on the options to the EG-added wrapper code. Also suggestion you turn on options mprint and source2. SAS clearly thinks it printed an error somewhere.
Respected Advisor
Posts: 4,173

Re: If else call execute

[ Edited ]

You need to expand the "plus" as else you're hiding the relevant parts of the log.

Capture.PNG

 

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.

Ask a Question
Discussion stats
  • 4 replies
  • 201 views
  • 0 likes
  • 3 in conversation