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?
Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!
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.
Ready to level-up your skills? Choose your own adventure.