I'm trying to write where any given macro variable can be numeric or character as the list of possible input value could be any integer, possibly preceded or followed by a character (i.ee = -1, 0, 1, d1, w9e), but something is off. See below for the simplified code:
Checking if variable is integer:
%macro isnum (mv);
%eval(not %sysfunc(verify(&mv,-0123456789)));
%mend isnum;
%macro DefineDate(dt1,dt2,dt3);
...
%do i = 1 %to 3;
%put Test dt&i. = &&dt&i.;
%if %length(&&dt&i.) ne 0 %then %do;
%put Variable dt&i. = &&dt&i.;
%if %isnum(&&dt&i.) = 1 %then %do;
%put dt&i. isnum successful;
%end;
%else %do;
%put dt&i. isnum did not run;
%put dt&i. numericity is %isnum(&&dt&i.);
%end;
%else %put dt&i. does not exist;
%end;
%mend;
%DefineDate(dm1,0)
The output to the log is:
Test dt1 = dm1 Variable dt1 = dm1 dt1 isnum did not run dt1 numericity is 0; Test dt2 = 0 Variable dt2 = 0 dt2 isnum did not run dt2 numericity is 1; Test dt3 = dt3 does not exist
I can't understand why I can't get the %IF conditional to run in the second step, despite it returning 1 in the identical put statement. Thank you
... View more