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.
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.
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
Yeah, I added that but still getting the name not resolved error.
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.
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?
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?
Personally I would put them in a SAS dataset and then call them from there. Really depends on how much information though.
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!
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.
Ready to level-up your skills? Choose your own adventure.