4gl - SAS %INCLUDE Statement - proceed even if an error -
i have code tells me went wrong in file a.sas
filename myfile email to=&e_mail. subject= "error" type="text/plain"; %macro errmail; %if &syserr ne 0 %then %do; data _null_; file myfile; put; put 'error'; put "&syserrortext"; put; put "log: \\logs" ; run; %end; %mend errmail; %errmail
i use %include function in file, when have there:
data a; infile "/usr/local/abc/load_file" dlm='09'x firstobs=2; input id age; run; proc sort data=_load_a. nodupkey; id; proc sql noprint; delete abc.my_table; quit; proc append base=abc.my_table; data=load_a. force; %include "/usr/local/abc/a.sas";
and if error here (before %include function) don't e-mail then. can use %include function if want information error before function?
below part of log, have error earlier , part of include function not done.
note: 129 records read infile "/usr/local/642.txt". minimum record length 25. maximum record length 25. note: data set work.load_642 has 129 observations , 3 variables. note: data statement used (total process time): real time 0.00 seconds cpu time 0.01 seconds 16 proc sort data=load_&nr. nodupkey; 17 id; 3 system sas 08:15 tuesday, may 10, 2016 note: there 129 observations read data set work.load_642. note: 0 observations duplicate key values deleted. note: data set work.load_642 has 129 observations , 3 variables. note: procedure sort used (total process time): real time 0.00 seconds cpu time 0.01 seconds 19 proc sql noprint; 20 delete a.642_id; sasxdbi: dbicon: special image sas/poland sasxdbi: dbicon: special image sas/poland note: 135 rows deleted a.642_id. 20 ! ; 21 quit; note: procedure sql used (total process time): real time 17.44 seconds cpu time 0.08 seconds 22 23 proc append base=a.642_id; sasxdbi: dbicon: special image sas/poland 23 ! data=load_&nr. force; ____ 180 error 180-322: statement not valid or used out of proper order. 24 25 %include "/usr/local/generic.sas"; note: statements not processed because of errors noted above. note: sas system stopped processing step because of errors. note: sas set option obs=0 , continue check statements. might cause note: no observations in data set. note: procedure append used (total process time): real time 1.20 seconds cpu time 0.07 seconds note: data statement used (total process time): real time 0.00 seconds cpu time 0.00 seconds
note &syserr variable reset after every step, written, detect whether error occurs in proc append step precedes %include statement.
that said, seen in log, if proc append errors may make sas enter syntaxcheck mode. see note sas set option obs=0. in state, no code executed, sas checks code compilation errors.
if want recover syntaxcheck mode, sas continue executing code occurs after error, add following options statement %errmail macro, before data _null_
step:
options obs=max replace nosyntaxcheck;
Comments
Post a Comment