02-13-2013 12:28 PM
I am trying to execute one simple macro in program:
Program calls macro library:
if _n_ eq 1 then
fmt contains the macro:
But its throwing me error:
ERROR 180-322: STATEMENT IS NOT VALID OR IT IS USED OUT OF PROPER ORDER.
Any ideas please? I am using SAS on Mainframes and fmt is the DD name which contains the library information for macro.
02-13-2013 12:50 PM
The macro isn't throwing a syntax error, SAS is! The following works:
if _n_ eq 1 then %wrthdr;
However, your macro won't appear to have done anything. If you wanted xxx to appear in the log, your macro should have used %put rather than put.
02-13-2013 01:13 PM
That syntax works for windows. In windows I have tested it works fine. But in mainframes it tries to call the macro from different position by using %include DDname,
where DDname contains the macro. When it tries to compile and go through the include statement and reached macro. It throws the error mentioned above.
Also the purpose of macro is to print multiple headers and then corresponding variable values. It will be called in different programs.
02-13-2013 01:03 PM
I can't find an error when I run this code:
if _n_=1 then %wrthdr;
Is there a little more context that could be helpful? Does the code run fine with the macro call in question commented out?
02-13-2013 01:21 PM
Did you try to run the code I sent in my last post?
I think you are trying use an if statement without wrapping it in a datastep. The following would produce the same error, on a windows system, that you are getting:
if _n_ eq 1 then %wrthdr;
02-13-2013 01:28 PM
I am calling it within data step only:
if _n_ eq 1 then;
Also to add, I just tested the piece of code works fine, when macro is coded within program, but since we are defining it externally, we have to include it using %include only if I am correct. But while doing %include it throws error as I mentioned in my very first post.
02-13-2013 02:39 PM
Just to be clear, you're saying that simply submitting the %INCLUDE fmt; throws the error?
If so, it's as if the code within the macro is being executed (rather than the macro just being compiled) when you %INCLUDE it. And I'm not sure why that would happen.
If you're actually trying to use a Stored Macro Library then use the following code instead of %INCLUDE:
options mstored sasmstore=fmt;
02-14-2013 01:16 PM
I tried libname option, its not able to recognize 'directory' name, as its not a windows operating system, and in mainframes stores in PDS: AAA.BBB.CCC
If the filename statement worked to establish the fileref fmt, so too should a libname statement using similar syntax, wouldn't you think?
Would you mind posting your filename statement for fmt?