I am trying to resolve the condition of the macro in my code. I have the two conditions where I want to output the error in log based on the input macro variable 'fld' . If it starts with numeric then it have to put one condition otherwise it need to put another error in log ( most of my names with 'SC' if its not numeric
In my example fld= 101-281 then I am expecting to print 'ERROR: 101281 starts with Numeric", My second one is mostly my name starts with 'SC' how can I control the second condition using the ':' colon in the % if condition to print 'ERROR:&dsn ( numeric values of the 'fld' name) starts with alpha character SC"
I am able to use ':' in dataset condition but not sure how to use it the macro, instead of writing every name in the 'If' Condtion.
Thank you for your inputs.
%macro check (fld=);
*%global output dsn;
%let output = %sysfunc(compress(&fld, "-"));
%if &output ^=: SC %then %do;
%let dsn= %substr(&output.,1,6);
data _281;
putlog "ERROR: &dsn starts with Numeric";
run;
%end;
%else %if &output = :SC %then %do;
%let dsn= %substr(&output.,3,6);
data _109;
putlog "ERROR:&dsn starts with alpha character SC";
run;
%end;
%put &output &dsn;
%mend;
%check (fld= 101-281);
%check (fld= 121-281);
%check (fld= SC100426);
%check (fld= SC100843);
%check (fld= SC102126);
%check (fld= SC105143);
... View more