Below is a simplified example of what I am trying to accomplish. I have a data set that has a character variable called MOD with values "N", "0", "1", ... "9". I am using a macro, stored in a separate file to condense the length of the program, to define a new variable called PRODUCT. The PRODUCT value in the third record in the output data set should be "SCOOTER" based on ID = "0001" and MOD = "6". However, I have something coded incorrectly because it is returning "BIKE". I suspect that it is in the IN operator since I haven't used this functionality in a macro before but I suppose it could be anything. Any help is appreciated. Thanks in advance.
%MACRO PRODUCT(ID, MOD) / MINOPERATOR;
%local M1;
%if &MOD = N %then %let M1 = N; %else %if %EVAL(&MOD in 6 8 9) %then %let M1 = Y; %else %let M1 = N;
if &ID = "0001" and "&M1" = "Y" then PRODUCT = "SCOOTER";
else if &ID = "0001" then PRODUCT = "BIKE";
else if &ID = "0002" then PRODUCT = "SKATEBOARD";
%MEND;
data TEST1;
infile datalines;
input ID $ MOD $;
length PRODUCT $ 10;
%PRODUCT(ID, MOD)
datalines;
0001 N
0001 0
0001 6
0002 8
;
run;
... View more