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

Hello, 

 

I'm trying to invoke a macro from my code but I keep getting this error:

 

WARNING:Apparent invocation of macro TEST not resolved. 

ERROR 180-322: Statement is not valid or it is used out of proper order.

 

This is the code that I'm calling the macro from:

Options                                                                                                                           
   Mautosource                                                                                                                    
   Sasautos = ('unix link where the test.sas file is located')                                                                                                 
   source2                                                                                                                        
   nocenter mlogic symbolgen                                                                                               
   ; 

%test(table.acct,acct);

 

when I copy paste the entire macro in the code, it runs fine. which confirms there is nothing wrong with the macro. Below is the macro definition in the file test.sas:

 

%macro test(table,var);

proc sql noprint;
        CONNECT TO teradata (user= "%sysget(user)" password = "&pass" tdpid="rchtera" mode=teradata);
		create table abc as select * from connection to teradata
	( select top 2 &var. from &table.);
	disconnect from teradata;
	quit;

%mend;

 

I even tried using %include, but that hasn't helped either. In any case I would prefer invoking without using %include.

 

Appreciate any help!

1 ACCEPTED SOLUTION

Accepted Solutions
Tom
Super User Tom
Super User

When you add a path into the SASAUTOS option and then ask to run a macro named TEST it will look for a file name 'test.sas' in that location. 

 

So what happens when you try:

%include 'unix link where the test.sas file is located/test.sas' ;
%test(table.acct,acct);

 

Unix can do strange things also.  Someone had an issue on this forum a little while ago because the actual name of the file ended in a space.  

View solution in original post

10 REPLIES 10
Quentin
Super User

What happens when you try to %include the file?  Does it not see test.sas?

 

Remember that on unix your file paths/names are case sensitive.  Also double check that your link is working.  Yet another possibility is that the account used to run the SAS job does not have read access to test.sas.

 

Also, within a SAS session SAS will only look for an autocall macro definition once, by default.  So once you see that message, it will not look again for the definition.  When debugging, it's sometimes helpful to change that by setting the system option MRECALL.

BASUG is hosting free webinars Next up: Mike Raithel presenting on validating data files on Wednesday July 17. Register now at the Boston Area SAS Users Group event page: https://www.basug.org/events.
AJ_Brien
Quartz | Level 8

I checked the link, no issues there with the access. There is no inconsistency in the name of the file either, the case and spelling match.

 

I tried include like this:

 

filename job "unix link where test.sas is located";
%include job(test);

 

This is what I get in logs:

WARNING: Physical file does not exist, /unix link/test.sas.
ERROR: Cannot %INCLUDE member test in the aggregate JOB.

 

Reeza
Super User

@AJ_Brien wrote:

I checked the link, no issues there with the access. There is no inconsistency in the name of the file either, the case and spelling match.

 

I tried include like this:

 

filename job "unix link where test.sas is located";
%include job(test);

 

This is what I get in logs:

WARNING: Physical file does not exist, /unix link/test.sas.
ERROR: Cannot %INCLUDE member test in the aggregate JOB.

 


What happens when you don't use a filename reference at all? If it can't find that path/program then it won't run. 

 

%include ' path to .sas file here';
AJ_Brien
Quartz | Level 8

I get this:

 

ERROR: Invalid file, 'path to .sas file'.
ERROR: Cannot open %INCLUDE file 'path to .sas file'.

 

But I queried a dataset that exists in that same link and was able to see that without any problem. So I definitely do not have any access issues and that path is definitely correct.

Reeza
Super User
Do you have the file name correct? The extension? The file doesn't exist for some reason? It's all lower case in both places like someone else mentioned?
Tom
Super User Tom
Super User

When you add a path into the SASAUTOS option and then ask to run a macro named TEST it will look for a file name 'test.sas' in that location. 

 

So what happens when you try:

%include 'unix link where the test.sas file is located/test.sas' ;
%test(table.acct,acct);

 

Unix can do strange things also.  Someone had an issue on this forum a little while ago because the actual name of the file ended in a space.  

AJ_Brien
Quartz | Level 8

This worked!

 

Could you please explain why did I have to use the include with the macro invocation? I've never seen anyone do that before?

 

ballardw
Super User

@AJ_Brien wrote:

This worked!

 

Could you please explain why did I have to use the include with the macro invocation? I've never seen anyone do that before?

 


When the %include is successful, assuming there is actual SAS code in the file, then that code is submitted for execution. In this case that likely means the macro was finally compiled.

The log likely had a note to that affect.

Tom
Super User Tom
Super User

Then the issue is the MRECALL option as previously mentioned. 

 

Perhaps your autoexec or some earlier code in the same SAS session already used that macro name and so SAS thinks it shouldn't have to look for the source again.

 

The MRECALL option is what tells it to try again.

Tom
Super User Tom
Super User

And the name of the file you included was literally test.sas and not something with one or more uppercase letters?  Like TEST.SAS or Test.SAS?

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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
  • 10 replies
  • 13778 views
  • 0 likes
  • 5 in conversation