DATA Step, Macro, Functions and more

Strange (but simple?) problem with macro

Not applicable
Posts: 1

Strange (but simple?) problem with macro

I'm having a strange problem running my macro. When I call the macro using the %include statement, SAS is unable to read any subsequent code in the main coding. It's like it can't tell the difference between the end of the macro and the start of the next section of code. However, when I paste the macro directly into my main code file, everything runs perfectly. I have checked and double-checked, and my addresses are correct and the macro code is identical. What could be the source of this inconsistency?
Super Contributor
Super Contributor
Posts: 3,176

Re: Strange (but simple?) problem with macro

The possibilities of your problem root-cause are numerous - your best approach to get some feedback is to post your code, preferably from the SAS log execution. Do pay attention to this useful forum post though when you COPY/PASTE your own code into your reply:毙

Of course, you should be including the OPTIONS statement below with your own desk-checking to rule-out coding syntax and logic possibilities contributing to your problem symptom:


Scott Barry
SBBWorks, Inc.
Posts: 24

Re: Strange (but simple?) problem with macro

if you forget to run the macro, but just inlcude it? or by document, you don't have to add a semicolon at the end when you call a macro, but I always add one if the macro is not only a part of open code statement.

%include "macroname";

open code;


if variable le %macroname then do;
SAS Employee
Posts: 58

Re: Strange (but simple?) problem with macro

I haven't been to the forum lately. Is this still an issue for you?

When you say "call the macro with %include" it's not clear if you mean that you're including the macro definition up front, then trying to execute it later in the program; or if you actually have the call to the macro in the code you're including.

Scott is right. If we can see your code we can probably help with this. If you aren't comfortable posting it here to a public forum, call SAS Technical Support and have them take a look.

Ask a Question
Discussion stats
  • 3 replies
  • 4 in conversation