BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
hellohere
Pyrite | Level 9

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

1 ACCEPTED SOLUTION

Accepted Solutions
ballardw
Super User

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.

View solution in original post

14 REPLIES 14
hellohere
Pyrite | Level 9

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++?!

Kurt_Bremser
Super User

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

hellohere
Pyrite | Level 9

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. 

sbxkoenk
SAS Super FREQ

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

ballardw
Super User

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.

hellohere
Pyrite | Level 9

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

Kurt_Bremser
Super User

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.

Ksharp
Super User
Try these options:


options errorabend nosyntaxcheck ;
hellohere
Pyrite | Level 9
this should be solution
SASKiwi
PROC Star

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. 

hellohere
Pyrite | Level 9

How to RUN in SAS/PC Batch mode?! how to save the LOG into a file?

SASKiwi
PROC Star

The SAS Windows Companion explains all this. Here is the link to batch processing.

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 14 replies
  • 1406 views
  • 3 likes
  • 6 in conversation