BookmarkSubscribeRSS Feed
glmer
Calcite | Level 5

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?

15 REPLIES 15
PaigeMiller
Diamond | Level 26

You don't have defined a macro named %ULCompositeQx, so SAS doesn't know what to do when it encounters you calling this macro.

--
Paige Miller
glmer
Calcite | Level 5

No I have those. Just not part of this snippet of code.

PaigeMiller
Diamond | Level 26

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.

--
Paige Miller
Reeza
Super User

Call execute could make this much simpler....

glmer
Calcite | Level 5

Could you write some indicative codes please?  For call executing them

Reeza
Super User

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;


glmer
Calcite | Level 5

thanks, but how will this work for 6 macros ULCompositeQx1-6.

RW9
Diamond | Level 26 RW9
Diamond | Level 26

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.

Reeza
Super User

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.

Astounding
PROC Star

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.

glmer
Calcite | Level 5

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.

Astounding
PROC Star

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.

RW9
Diamond | Level 26 RW9
Diamond | Level 26

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. 

glmer
Calcite | Level 5

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

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
  • 15 replies
  • 1375 views
  • 2 likes
  • 5 in conversation