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-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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
  • 6 replies
  • 1675 views
  • 0 likes
  • 3 in conversation