Help using Base SAS procedures

Macro not working and several errors

Reply
Occasional Contributor
Posts: 19

Macro not working and several errors

options mprint;
 %MACRO V22I9ED1(AGE=, SEX=, ICD9= );

   IF &SEX= "2" AND &ICD9 IN ("2860", "2861")  THEN CC=" 48 "; 
   ELSe IF &AGE < 18 AND &ICD9 IN ("4910", "4911", "49120", "49121", "49122",
                              "4918", "4919", "4920", "4928", "496",  
                              "5181", "5182") THEN CC=" 112 ";
   ELSE IF &AGE < 18 AND &ICD9 IN ("49320", "49321", "49322") 
                                              THEN CC=" -1 ";

 
%IF &SEDITS = 1 %THEN %DO;
    
     _TAGE=PUT(&ICD9, $&AGEFMT9..);
     IF _TAGE NE "-1" AND
        (&AGE < INPUT(PUT(_TAGE, $AGEL.),8.) OR
         &AGE > INPUT(PUT(_TAGE, $AGEU.),8.)) THEN CC='-1';

    
     _TSEX=PUT(&ICD9, $&SEXFMT9..);
     IF _TSEX NE "-1"  & _TSEX NE &SEX THEN CC='-1';

  %END;
 %MEND V22I9ED1;

Error is attached below: Could somebody please help me with it?

 

Capture.PNG

Occasional Contributor
Posts: 19

Requesting help with macro error

options mprint;
 %MACRO V22I9ED1(AGE=, SEX=, ICD9= );

   IF &SEX= "2" AND &ICD9 IN ("2860", "2861")  THEN CC=" 48 "; 
   ELSe IF &AGE < 18 AND &ICD9 IN ("4910", "4911", "49120", "49121", "49122",
                              "4918", "4919", "4920", "4928", "496",  
                              "5181", "5182") THEN CC=" 112 ";
   ELSE IF &AGE < 18 AND &ICD9 IN ("49320", "49321", "49322") 
                                              THEN CC=" -1 ";

 
%IF &SEDITS = 1 %THEN %DO;
    
     _TAGE=PUT(&ICD9, $&AGEFMT9..);
     IF _TAGE NE "-1" AND
        (&AGE < INPUT(PUT(_TAGE, $AGEL.),8.) OR
         &AGE > INPUT(PUT(_TAGE, $AGEU.),8.)) THEN CC='-1';

    
     _TSEX=PUT(&ICD9, $&SEXFMT9..);
     IF _TSEX NE "-1"  & _TSEX NE &SEX THEN CC='-1';

  %END;
 %MEND V22I9ED1;

Attached is the error message


Capture.PNG
Super User
Posts: 17,912

Re: Requesting help with macro error

You  need to post more of your log, specifically, how are you calling the macro.

 

 

Super User
Posts: 10,538

Re: Requesting help with macro error

And run the code with OPTIONS MPRINT;

Many times the displayed error message is way after the line of code with the issue and MPRINT helps with that plus showing the resolved values of the macro code.

 

 

Ask a Question
Discussion stats
  • 3 replies
  • 245 views
  • 0 likes
  • 3 in conversation