DATA Step, Macro, Functions and more

Brand new to SAS - Please help - stuck at first hurdle!!! Macro Frustratio

Reply
N/A
Posts: 0

Brand new to SAS - Please help - stuck at first hurdle!!! Macro Frustratio

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.
N/A
Posts: 0

Re: Brand new to SAS - Please help - stuck at first hurdle!!! Macro Frustratio

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
N/A
Posts: 0

Re: Brand new to SAS - Please help - stuck at first hurdle!!! Macro Frustratio

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!
Super Contributor
Posts: 359

Re: Brand new to SAS - Please help - stuck at first hurdle!!! Macro Frustratio

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.
N/A
Posts: 0

Re: Brand new to SAS - Please help - stuck at first hurdle!!! Macro Frustratio

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!
Ask a Question
Discussion stats
  • 4 replies
  • 113 views
  • 0 likes
  • 2 in conversation