%IF Statement and Macro resolution

Accepted Solution Solved
Reply
New Contributor mc
New Contributor
Posts: 4
Accepted Solution

%IF Statement and Macro resolution

Hey. So I'm trying to execute a macro subroutine using the conditional statements %IF-%THEN. The following is the code I'm trying to run:

OPTIONS MPRINT MLOGIC;
%macro new_seg(cod,seg,bus_seg);
 data client;
  set client;
   %if cod_seg2="&cod" %then %do;
     new_seg="&seg";
     new_bus_seg="&bus_seg";
    %end;
 run;
%mend new_seg;

%new_seg(RE,REAL ESTATE,REAL ESTATE);

Everytime I try to execute the code, it gets stuck at the %IF statement and says the following: "MLOGIC(NEW_SEG): %IF condition cod_seg2="&cod" is FALSE". I'm not sure why it says it's false since the variable cod_seg2 in my dataset does have 'RE' as a value. Is SAS not resolving to the correct value of the parameter or am I not explicitly coding the conditional statement correctly?


Accepted Solutions
Solution
‎10-29-2015 11:53 AM
Respected Advisor
Posts: 3,786

Re: %IF Statement and Macro resolution

Change the %IF %THEN %DO %END to IF THEN DO END

View solution in original post


All Replies
Solution
‎10-29-2015 11:53 AM
Respected Advisor
Posts: 3,786

Re: %IF Statement and Macro resolution

Change the %IF %THEN %DO %END to IF THEN DO END
New Contributor mc
New Contributor
Posts: 4

Re: %IF Statement and Macro resolution

That did the trick. Thanks for your help!
🔒 This topic is solved and locked.

Need further help from the community? Please ask a new question.

Discussion stats
  • 2 replies
  • 361 views
  • 1 like
  • 2 in conversation