BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
mc
Fluorite | Level 6 mc
Fluorite | Level 6

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?

1 ACCEPTED SOLUTION

Accepted Solutions
data_null__
Jade | Level 19
Change the %IF %THEN %DO %END to IF THEN DO END

View solution in original post

2 REPLIES 2
data_null__
Jade | Level 19
Change the %IF %THEN %DO %END to IF THEN DO END
mc
Fluorite | Level 6 mc
Fluorite | Level 6
That did the trick. Thanks for your help!

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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
  • 2 replies
  • 705 views
  • 1 like
  • 2 in conversation