BookmarkSubscribeRSS Feed
Gregor
Obsidian | Level 7

My problem is

I have a sas code embedded into an enterprise guide project.

The code does what I want it to do - I rather complicated recursive macro which has a defined result.

There is one last table  which is is created fine, so there shouldn't be an endless recursion or endless loops.

However,  executing the code, the code symbol stays green, and the following steps stay yellow, and don't get executed.

It can only be stopped by disconnecting the sas system.

What could go wrong?

Thanks

Gregor


8 REPLIES 8
Amir
PROC Star

Hi Gregor,

Can you post the code and the log?

Regards,

Amir.

Gregor
Obsidian | Level 7

There was no log when I ended the process. The file lib.cashflows looks perfect.

I cannot attach the code here because the browser doesn't let me cut and paste

Here is a picture of the end of the macro read_alle and the execution statement of it:code.jpg

There are some loops before that, but they all end perfectly befroe the data step with the creation of

lib.cashflows is executed.

Is there some sort of quit or run statement missing?

Thanks

Gregor


Amir
PROC Star

Hi,

Perhaps try temporarily commenting out the call to the macro function read_alle and just code a data step to output lib.cashflows to see if it is the macro function that is causing the issue.

Regards,

Amir.

Gregor
Obsidian | Level 7

code2.jpg

works fine. If tht's what you mean.

Amir
PROC Star

Hi,

Yes that is what I meant. If the following steps are executed, then this shows the issue is in the macro.

Have you tried using the following options before you call the macro function?:

options mprint macrogen symbolgen;

If you're able to capture the log, the options should show you more information about the macro code, for example, what values macro variables are resolving to, which should help diagnose issues such as Tom described.

Regards,

Amir.

data_null__
Jade | Level 19

Click the HTML button on the editor and insert HTLM formatted text.  Copy can copy as HTML from EG program editor if you happen to be using EG.

Tom
Super User Tom
Super User

What is the test that the macro uses to stop the recursion?  You should concentrate on that because it sounds like the recursion is continuing longer than you expected.

A common mistake with macros is to reference a macro variable within a macro without being clear whether the macro variable is local to this instance of the macro, global, or simply "external" to the current instance (either global or locally defined in an outer macro execution scope).

When this gets messed up there are two main risks:
1) It can either not return the value to the caller because the macro is local and its value disappears when the macro execution finishes.

2) It can override the instance of the macro variable a calling macro scope is using and cause an impact on the branching or looping of the calling macro.

Sometimes this is masked in testing because you might have already created a global macro variable with the same name that is used by your macro, but then when you re-run the macro in a new session that global macro variable does not exist and the macro variable becomes local to the macro execution environment.

Gregor
Obsidian | Level 7

Hi everybody. I am very sorry that I haven't responded to your posts. My problem was depriorized by pre holiday stress, and when I came back from my vacations, the program suddenly ran perfectly. I know this was very bad style. Sorry again.

Gregor

sas-innovate-2024.png

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.

 

Register now!

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

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
  • 8 replies
  • 1551 views
  • 0 likes
  • 4 in conversation