- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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++?!
- Tags:
- .
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Tags:
- is
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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
- Tags:
- uiui
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
options errorabend nosyntaxcheck ;
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
How to RUN in SAS/PC Batch mode?! how to save the LOG into a file?
- Tags:
- m
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
The SAS Windows Companion explains all this. Here is the link to batch processing.