Related Posts

2 users responded to this post

ljo said in November 9th, 2008 at 1:49 am    

Hello,

As matter of fact, the SAS documentation presents a warning relatively to your issue. But, I have to admit that it doesn’t say why it is like that, and I don’t have the answer.

“A macro definition must precede the invocation of that macro in your code. The %MACRO statement can appear anywhere in a SAS program, except within data lines. A macro definition cannot contain a CARDS statement, a DATALINES statement, a PARMCARDS statement, or data lines. Use an INFILE statement instead.”
in Help / Macro Language Dictionary / %MACRO Statement, SAS V9.1

But does it really matter? As you wrote it, there is always an alternative solution with SAS. And sometimes, I have to say it’s not always pertinent to put everything in a macro. A review of the way you are building your application/program can be the solution because it helps to get things done in a most understandable way.

John said in November 9th, 2008 at 4:27 pm    

That warning in the SAS Documentation is certainly consistent with all that I have seen on the subject. It makes me wonder whether DATALINES, etc. would throw out the SAS Macro processor for some reason but I have yet to see that confirmed anywhere. Your comments on program design are certainly pertinent since I have been planning to get what I was creating to read in from a text file but that’s on hold pending the resolution of other things first.

Leave a Comment