BookmarkSubscribeRSS Feed
deleted_user
Not applicable
Hi - I have done a lot of coding in Matlab - but am brand new to SAS. I can already see the parallels to Matlab - particularly with the SAS macros - which I can see I HAVE to master to get the most out of the thing. However, I am having a frustrating time, right at the outset - not able to get even the simplest of macros to work. My problem is, every time I try and run it, I get: "WARNING: Apparent invocation of macro OFFSPRING_ANALYSIS_MACRO not resolved."

Now, I have been reading online for 2 days solid - and have read most everything around this issue, and still cant seem to nail it!!! Thats why I'm here! I have gone over it with a fine tooth comb - the macro name matches the definition name - I am using SASAUTOS to specify my macro location....I realise there could be a problem here but it all looks OK...which leaves an error in the macro definition as the only other source of error I can think of... To not be able to get over this first step is really frustrating, as I feel the main chunk of logic flow and all that is not too far beyond me - but if you cant even get started... OK so below I will show you exactly what code I am using - please can somebody point out what I'm doing wrong? Thanks in advance!

I have two programs - one is a calling program - which I am trying to use to call my macro - which is the other program. So, in my calling program, I have the following:

/*************************************************************************************/
/*This is the calling program*/

%LET mainroot = C:\Users\Dave\Documents\Evolution Work;

OPTIONS SASAUTOS= ("&mainroot\Macros") MLOGIC mprint MERROR SERROR SYMBOLGEN MAUTOSOURCE MCOMPILENOTE=all NOTES SOURCE SOURCE2;

%Let dependant = Av_Baby_TL;
%Let cov = Av_baby_SVL_1 ;
%Let fixed = Species;
%Let fac1 = Offspring_Sex;

%offspring_analysis_macro(&dependant,&cov,&fixed,&fac1);

/*************************************************************************************/
/*And this is the macro that I am trying to call above - named offspring_analysis_macro */

%macro offspring_analysis_macro(dependant,cov,fixed,fac1);
proc glm data = Sexratio.Offspring;
class &fixed &fac1 ;
model &dependant = &cov &fixed &fac1 /solution;
run;
%mend offspring_analysis_macro;


/*************************************************************************************/
/*And thats it! the macro is held in the location specified up in the calling routine - the calling routine is kept elsewhere The dataset Sexratio.Offspring is in one of my libraries called Sexratio - that I have been using for manual analysis (i.e. non macro analysis)*/


Thanks a lot for taking the time to help out and I look forward to getting over this first sticky wicket!!

All the best

Davo.
4 REPLIES 4
deleted_user
Not applicable
I assume you have saved the macro code in a file in the sasauto directory. You know the file MUST have the same name as the macro?

i.e.

offspring_analysis_macro.sas
deleted_user
Not applicable
yes I have quadruple checked all of that - it must be something else - maybe I am only passing text into my macro parameters, or there is something wrong inside my macro that needs changing - aparently you get this error warning even if the only problem is that there is a bug in your macro code somewhere....does it look OK? How about my use of the ampersand inside the macro when I use the parameter variables that I passed in? Because they had already been passed in with am ampersand from the outside...? I have been trying all manner of other ideas but frustratingly just keep being told the same error message!! Can't get passed it!
Flip
Fluorite | Level 6
Execute the macro definition manually and then try your macro run. If that works it could be something about your path. Make sure that that space in your path is not messing things up.

I see it now... after your &mainroot macro var you need a delimiter to mark the end. so you need &mainroot.\
The . denotes the end of the macro var so the \ is kept. Otherwise the \ is used as a delimiter and dissappears.
deleted_user
Not applicable
Thanks SO MUCH for helping me out - it works!!! I think it was just the gap in my path name!!!! Oh well, two days of research an d rewriting and rewriting - I should have thought to check that!!!!!!! Thanks a lot for your help!

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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
  • 684 views
  • 0 likes
  • 2 in conversation