I have the following macro MD –
-----------------------------------------------------------------------------------------------------
%macro MD(DIR);
%LET COUNT=0;
%LET DLM=\;
%IF %SUBSTR(&DIR,%LENGTH(&DIR),1) NE &DLM %THEN %DO;
%LET DIR=&DIR&DLM;
%END;
%DO J=1 %TO %LENGTH(&DIR);
%IF %SUBSTR(&DIR,&J,1)=&DLM %THEN %DO;
%LET COUNT=%EVAL(&COUNT+1);
%END; %END;
%LET DRIVE=%SUBSTR(&DIR,1,3);
%LET LEVEL=&DRIVE;
%DO I=2 %TO &COUNT;
%LET WORD=%SCAN(&DIR,&I,&DLM);
%LET LNEW=&LEVEL&WORD&DLM;
data _null_;
*rc=filename('newdir',"&lnew");
*c=dopen('newdir');
*if c=0 then new=dcreate("&word","&level");
%PUT "mkdir "&lnew"";
%PUT "cd "&lnew"";
run;
%LET LEVEL=&LNEW;
%END;
%mend;
When I invoke it with %MD("C:\test1\test2");
I am getting the following error in the log
MLOGIC(MD): Beginning execution.
MLOGIC(MD): Parameter DIR has value "C:\test1\test2"
MLOGIC(MD): %LET (variable name is COUNT)
MLOGIC(MD): %LET (variable name is DLM)
SYMBOLGEN: Macro variable DIR resolves to "C:\test1\test2"
SYMBOLGEN: Macro variable DIR resolves to "C:\test1\test2"
SYMBOLGEN: Macro variable DLM resolves to \
ERROR: A character operand was found in the %EVAL function or %IF condition where a numeric operand is required.
The condition was: %SUBSTR(&DIR,%LENGTH(&DIR),1) NE &DLM
ERROR: The macro MD will stop executing.
Appreciate any quick help