Hi, I have the following code, then input "2021JUNUN" should fall in 2nd condition &idx1_dw=%eval(&idx2_dw + 1) , which give the result : after dw is 2021JUNUN %macro DROPUN(S);
%let idx2_dw=%sysfunc(index(&s,JUN));
%let idx1_dw=%sysfunc(index(&s,UN));
%if &idx2_dw=0 %then %do;
%let cfun=%sysfunc(tranwrd(&S,UN,'07'x));
%let cfun=%sysfunc(compress(&cfun,'07'x));
%end;
%else %if &idx1_dw=%eval(&idx2_dw + 1) %then %do;
%let cfun=%qsysfunc(tranwrd(&S,%str(UNUN),%str(UN)));
%let cfun=%qsysfunc(tranwrd(&S, %str(UN/UN), %str(UN)));
%end;
%else %if &idx1_dw=1 %then %do;
%let l_dw=%eval(%length(&S)-2);
%let cfun=%substr(&S,3,&l_dw);
%end;
%put after dw is &cfun;
%mend DROPUN;
%dropun(2021JUNUN); However, when I put the code outside, it gives me correct result: 2021JUN %let s=2021JUNUN;
%let cfun=%qsysfunc(tranwrd(&S,%str(UNUN),%str(UN)));
%put &cfun;
%dropun(2021JUNUN); Can anyone please advise what is the issue here? Many thanks in advance!
... View more