DATA Step, Macro, Functions and more

Strange (but simple?) problem with macro

Reply
N/A
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,174

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:

http://support.sas.com/forums/thread.jspa?messageID=27609毙

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:

OPTIONS SOURCE SOURCE2 MACROGEN SYMBOLGEN MLOGIC MPRINT;

Scott Barry
SBBWorks, Inc.
Contributor
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;
...
%macroname;
...

unless:

if variable le %macroname then do;
end;
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.

--Pat
Ask a Question
Discussion stats
  • 3 replies
  • 171 views
  • 0 likes
  • 4 in conversation