I want to know how should I exactly point out the error location in an included sas macro.
e.g. If I am calling an included macro the log only tells me that error occured at the line where I call the macro. I have no information about where to serarch inside that huge included macro.
ex. the log looks like below.
%include "/abc/getMyOutput.sas";
5%getMyOutput();
6
7
NOTE: Division by zero detected at line 5 column x.
WARNING: Limit set by ERRORS= option reached. Further errors of this type will not be printed.
RULE: ----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0
Any idea how I can see where inside that macro real problem occurs.
Thanks for your time.
See below code example.
data y;
c=5;
run;
%include "./include.sas";
%getit;
%macro getit;
data x;
set y;
a=5;
b=c/0;
run;
%mend getit;
options mprint symbolgen;
Set the options above and you'll get the code in your log and you should be able to track the issue.
In addition to the two options that @Reeza recommended, I'd also include the mlogic option.
Art, CEO, AnalystFinder.com
I added all the options but it still does the same thing. see below.
1 options symbolgen mlogic mprint;
2
3 data y;
4 c=5;
5 run;
NOTE: The data set WORK.Y has 1 observations and 1 variables.
NOTE: DATA statement used (Total process time):
real time 0.00 seconds
cpu time 0.02 seconds
6 %include "/include.sas";
18 %getit;
MLOGIC(GETIT): Beginning execution.
MPRINT(GETIT): data x;
MPRINT(GETIT): set y;
MPRINT(GETIT): a=5;
MPRINT(GETIT): b=c/0;
MPRINT(GETIT): run;
NOTE: Division by zero detected at line 18 column 26.
2 The SAS System 16:19 Wednesday, August 30, 2017
WARNING: Limit set by ERRORS= option reached. Further errors of this type will not be printed.
c=5 a=5 b=. _ERROR_=1 _N_=1
NOTE: Mathematical operations could not be performed at the following places. The results of the operations have been set to
missing values.
Each place is given by: (Number of times) at (Line):(Column).
1 at 18:26
NOTE: There were 1 observations read from the data set WORK.Y.
NOTE: The data set WORK.X has 1 observations and 3 variables.
NOTE: DATA statement used (Total process time):
real time 0.00 seconds
cpu time 0.00 seconds
MLOGIC(GETIT): Ending execution.
See above the place is given by line 18: column 26
Now if you see above line 18 is the macro call. So it does not say inside the macro where exactly the error occurs.
Add SOURCE2 to your %INCLUDE statement as well.
Note that the error does tellyou the data set so hopefully that should allow you to see the section of code that needs fixing.
NOTE: There were 1 observations read from the data set WORK.Y.
NOTE: The data set WORK.X has 1 observations and 3 variables.
Yes, but what if you have hundreds of calculation in that data step. If it points me to a specific line then it is very easy.
And turn of the options after you get things fixed:
options nomprint nosymbolgen nomlogic;
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
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.