invoke_e macro,
i have this following code::
%MACRO GenerateVariables ;
%GLOBAL stUID Macro stMedInd stMCC stSex intAge intDur stPcode intIssueyr;
%END;
%GLOBAL N;
DATA _NULL_
SET Output.ULExtract&SYear END = LAST;
CALL SYMPUT(COMPRESS('stUID'||_N_), Polnum);
CALL SYMPUT(COMPRESS('Macro'||_N_), stMacroName);
CALL SYMPUT(COMPRESS('stMedInd'||_N_), MedInd);
CALL SYMPUT(COMPRESS('stMCC'||_N_), Uncd);
CALL SYMPUT(COMPRESS('stSex'||_N_), Mysex);
CALL SYMPUT(COMPRESS('intAge'||_N_), issage);
CALL SYMPUT(COMPRESS('intDur'||_N_), Duration);
CALL SYMPUT(COMPRESS('stPcode'||_N_), Plancode);
CALL SYMPUT(COMPRESS('intIssueyr'||_N_), efyr);
IF LAST THEN CALL SYMPUT('N',_N_);
RUN;
%MEND;
%MACRO RunCompositeQx;
%DO i = 1 %TO &N;
%ULCompositeQx&&Macro&i(&&stUID&i,&&Macro&i,&&stMedInd&i,&&stMcc&i,&&stsex&i,&&intAge&i,&&intDur&i,&&stPcode&i,&&intIssueyr&i);
PROC SQL NOPRINT;
INSERT INTO Work.Output VALUES (&stPolnum, &CompQx1, &CompQx2);
QUIT;
%END;
%MEND;
%MACRO FinalRun;
/*%DO j = 1 %TO &FracChunk;*/
%GenerateVariables;
%RunCompositeQx;
%MEND;
%FinalRun;run;
This is throwing up the following error:
ERROR 22-322: Syntax error, expecting one of the following: a quoted string, a numeric constant,
a datetime constant, a missing value, MISSING, NULL, USER.
and
LINE and COLUMN cannot be determined
WARNING: Apparent invocation of macro ULCompositeQx not resolved.
Could you please help me get this macro working please?
You don't have defined a macro named %ULCompositeQx, so SAS doesn't know what to do when it encounters you calling this macro.
No I have those. Just not part of this snippet of code.
But SAS is telling you
WARNING: Apparent invocation of macro ULCompositeQx not resolved.
As far as I can see, you also don't have valid code for macro GenerateVariables. The line %end; just under the first %global causes this macro to fail.
Call execute could make this much simpler....
Could you write some indicative codes please? For call executing them
You'll have to probably redesign portion but this would be the gist of it:
data _null_;
set Output.ULExtract&SYear;
string = cats("%ULCompositeQx(", catx(",", stUID, Macro,stMedIni,stMcc,stsex,intAge,intDur,stPcode,intIssueyr), ");");
call execute(string);
run;
thanks, but how will this work for 6 macros ULCompositeQx1-6.
data _null_;
do i=1 to 6;
call execute('%ULCompositeQx'||strip(put(i,best.))||' (paramters);');
end;
run;
Perhaps post some test data, and required output as I fully agree with Reeza, you appear to be vastly over-complicating your code. Check out arrays for example.
I doubt there's a good reason for 6 versions of a macro - make one version and pass the number in as a parameter to then do some other logic in the code.
Have you tried replacing this line:
%ULCompositeQx&&Macro&i
This might work better:
%unquote(%ULCompositeQx&&Macro&i)
It could be a matter of tokenization not being properly interpreted.
i used this :
%MACRO RunCompositeQx;
%DO i = 1 %TO &N;
%unquote(%ULCompositeQx&&Macro&i)(&&stUID&i,&&Macro&i,&&stMedInd&i,&&stMcc&i,&&stsex&i,&&intAge&i,&&intDur&i,&&stPcode&i,&&intIssueyr&i);
PROC SQL NOPRINT;
INSERT INTO Work.Output VALUES (&stPolnum, &CompQx1, &CompQx2);
QUIT;
%END;
%MEND;
but still got the following errors:
22: LINE and COLUMN cannot be determined.
ERROR 22-322: Syntax error, expecting one of the following: a quoted string, a numeric constant,
a datetime constant, a missing value, +, -, MISSING, NULL, USER.
Then I would recommend getting rid of the macro language, to narrow down the error.
This is actually easier than it sounds. Take a look at the MFILE and MPRINT combination of options. They will let you save the code generated by the macro, in a separate file. Then run the file which will contain the generated code but no macro language. The error message you get will be much cleaner to interpret.
Good luck.
Precisely why I avoid macros:
%unquote(%ULCompositeQx&&Macro&i)(&&stUID&i,&&Macro&i,&&stMedInd&i,&&stMcc&i,&&stsex&i,&&intAge&i,&&intDur&i,&&stPcode&i,&&intIssueyr&i);
That to me is the epitome of obfuscation. What is it your trying to achieve? Post test data and example output.
I tried the Mprint and MFile options and there is a problem with the (%ULCompositeQx&&Macro&i)(&&stUID&i,&&Macro&i,&&stMedInd&i,&&stMcc&i,&&stsex&i,&&intAge&i,&&intDur&i,&&stPcode&i,&&intIssueyr&i
stement...
the demacroed code is %ULCompositeQx .(000123033 , ., ., ., ., 42, .,12985, 2001);
so its recognizing the variables properly but not the correct macro number...i have macros ULcomposite 1-6
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.