Running huge codes with macro, ERROR happens, and codes keep running.
How to stop the RUN if ERROR happens. And let it RUN over, if no ERROR happens.
Thanks
Are you using OPTIONS MPRINT to debug the code?
Do you know where the error is? If not, then the above should show the first error(s) to address.
Or modify your macro to test the result from every proc or data step to see if it completed without problems and put the suggested skip in MANY places if the code is actually that long.
Or may possibly break up a large macro to smaller ones that can be run in pieces testing at those boundaries.
If you know where the error happens, you can add a %GOTO depending on the value of &SYSSC that jumps to the end of the macro.
The issue is that I do not know where the ERROR is happening(I turned off LOG, a must otherwise prompt).
Anything in SAS has breakpoint like C/C++?!
Rule #1 of macro coding: start with working non-macro code.
Get your code to run successfully without any macro language use before you start making it dynamic
Yes, it is the way to build up Macros. The thing is when you indeed do that, RUN and no ERROR surely.
BUT later change needed, and ERROR somewhere.
Turn on the log.
Run each step in the macro individually, and set the macro variables manually with %LET as the macro logic would set them.
Hello,
For a %GOTO example (as said by @Kurt_Bremser ), see :
SAS® 9.4 and SAS® Viya® 3.5 Programming Documentation
Macro Language Reference
%GOTO Macro Statement
Example: Providing Exits in a Large Macro
https://go.documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/mcrolref/p0jfeh75p72icen1ddd9una5zbmm.htm
Also, this article might be useful :
How to conditionally stop SAS code execution and gracefully terminate SAS session?
By Leonid Batkhan on SAS Users March 24, 2021
https://blogs.sas.com/content/sgf/2021/03/24/how-to-conditionally-stop-sas-code-execution-and-gracef...
Koen
Are you using OPTIONS MPRINT to debug the code?
Do you know where the error is? If not, then the above should show the first error(s) to address.
Or modify your macro to test the result from every proc or data step to see if it completed without problems and put the suggested skip in MANY places if the code is actually that long.
Or may possibly break up a large macro to smaller ones that can be run in pieces testing at those boundaries.
I cannot turn on LOG since it quickly fills up and prompts. Try to turn on, and save LOG into file, not know how to
do that(it says error msg).
Using sleep() to debug, but too painful
Without the log, any attempt at debugging is futile, PERIOD.
You MUST have a log to see what's happening and when.
A single step (as I proposed) cannot fill up the log quickly, and if, you can look at the log before clearing it.
Run your job in batch mode. You will never be prompted regarding log size in batch. The SYNTAXCHECK option is also set on by default in batch and that should cause you program to run quickly to completion without processing any data.
How to RUN in SAS/PC Batch mode?! how to save the LOG into a file?
The SAS Windows Companion explains all this. Here is the link to batch processing.
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.
Ready to level-up your skills? Choose your own adventure.