12-18-2011 05:11 PM
I am using SAS to write SAS code to a external dataset, which will later be brougt in by using a %include.
The SAS code being written contains macro calls.
I was very surprised to find that SAS was trying to resolve the macro call as I was writing it to the external file. Obviously not the ime I want this to occur.
How do I prevent SAS from trying to resolve these macro calls while I am writing the code to the external file?
12-18-2011 09:29 PM
Could you post a sample of the code that's giving you problems? This code writes SAS macro code to an external text file, and doesn't resolve until the later %INCLUDE.
data _null_; file 'test.txt'; put '%PUT NOTE: The date is %sysfunc(today(),mmddyy10.);'; run; /* Open and read the text file - the macro code is not yet resolved... */ %include 'test.txt';
12-18-2011 10:20 PM
Or You can turn Macro language off before starting SAS by using
SAS option MACRO is valid only at startup of the SAS System or startup of a SAS
process. The SAS option is ignored.
Another way is to use macro quote functions to mask these maro variables.
12-19-2011 12:51 PM
You don't say how you are writing the text file. If using PUT statements I would suspect something that should be quoted isn't. The other is the difference between "%somemacrotext" and '%somemacrotext' where the first will attempt to resolve and the second doesn't.