BookmarkSubscribeRSS Feed
steve_citi
Calcite | Level 5

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?

4 REPLIES 4
SASJedi
SAS Super FREQ

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';
Check out my Jedi SAS Tricks for SAS Users
Ksharp
Super User

Or You can turn Macro language off before starting SAS by using

options nomacro;

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.

Ksharp

ballardw
Super User

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.

Saugata
Obsidian | Level 7

This certainly helped my case Smiley Happy

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 4 replies
  • 1298 views
  • 1 like
  • 5 in conversation