BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
sasboy007
Calcite | Level 5

Hi all,

I have a txt file called mytext that has the following:

%LET name1=Customers;

And then in my SAS program I have:

filename macro1 "C:\mytext.txt";

%include macro1;

create table mylib.&name1_new as select * from
connection to oracle(

select *
from old_customers
);

run;

Everything in the my SAS program works However, I'm getting a "WARNING: symbolic reference error for name1 not resolved." Is the problem the macro setup in the text file?

Thanks.

1 ACCEPTED SOLUTION

Accepted Solutions
sasboy007
Calcite | Level 5

Ok I think I figured it out.

I had to place the below inside my proc sql statement.  Before it was was sitting outside and most likely not in the same "scope".

filename macro1 "C:\mytext.txt";

%include macro1;

Unless there is a better way of doing it.  Thanks.

View solution in original post

6 REPLIES 6
nehareddy
Calcite | Level 5

While using a macro name &name1 in a program, I think you need to use the delimiter "." at the end of your macro name which tells SAS, it's the end of the macro name. Like in  &name1._new

sasboy007
Calcite | Level 5

Yeah, I added that but still getting the name not resolved error. 

sasboy007
Calcite | Level 5

Ok I think I figured it out.

I had to place the below inside my proc sql statement.  Before it was was sitting outside and most likely not in the same "scope".

filename macro1 "C:\mytext.txt";

%include macro1;

Unless there is a better way of doing it.  Thanks.

RW9
Diamond | Level 26 RW9
Diamond | Level 26

Well, I think that if you put options mlogic syblogen mprint; on you may see that the thing resolves as something like:

create table mylib.Customers    _new as ...

The macro variable may need %trim'ing.

I have to say though, why create macro variables in an include file? 

sasboy007
Calcite | Level 5

Reason I put macro variables in include file is because I have 5 different SAS files that generate SQL "where" statements.  Instead of going into each SAS file and updating "Where" statements I have one universal Include file which handles variable assignment.  What do you think?

RW9
Diamond | Level 26 RW9
Diamond | Level 26

Personally I would put them in a SAS dataset and then call them from there.  Really depends on how much information though.

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 6 replies
  • 2181 views
  • 0 likes
  • 3 in conversation