Hi to whom it may concern, ´firstly thank you for your time. How do I execute two %macros in within the same statement line, i.e. the nested per se macro is executed first and the result of this first macro is then used by the second macro? i.e. %let response = %macroname_left(%(macroname_right(value,12),8); For example you have the value '???????12345678.dat' but you only want the numeric part '12345678', the '????' section could be any length, hence %subtr() doesn't because we can't determin where the starting postion could be, but we do know that the string value always ends with '.dat', hence if we take the right 12 first and the from that returned value, '12345678.dat', take the left 8, we'd be left with '12345678', correct? Correct. In Excel or Access VBA I would have used the combination of the LEFT and RIGHT fuctions like LEFT(RIGHT("???????12345678.dat",12),8) and the returned result would be '12345678'. Hence who I can I achieve this macro combination within same commend statement line? I would have like to have attached a file but can't due to security issues, hence see the code below. Although this is what I'd like to be able to do which does not work yet... %fncSTR_LEFT(%fncSTR_RIGHT('???????????????_12345678.dat', 12), 8); ... but currently in order to get around this limitation I've put the statement in two command lines a refer to a global paramter return. %fncSTR_RIGHT('???????????????_12345678.dat', 12); shows 12345678.dat %fncSTR_LEFT("&return.", 8); shows 12345678 %global return; %macro fncSTR_LEFT(str, len); data _null_; call symputx('return', substr(&str.,1,&len.), 'g'); run; %put &return.; %mend fncSTR_LEFT; %macro fncSTR_MID(str, start, len); data _null_; call symputx('return', substr(&str.,&start.,&len.),'g'); run; %put &return.; %mend fncSTR_MID; %macro fncSTR_REVERSE(str); data _null_; call symputx('return', reverse(&str.),'g'); run; %put &return.; %mend fncSTR_REVERSE; %macro fncSTR_RIGHT(str, len); data _null_; call symputx('return', reverse(substr(reverse(&str.),1,&len.)),'g'); run; %put &return.; %mend fncSTR_RIGHT; /* %fncSTR_RIGHT('???????????????_12345678.dat', 12); %fncSTR_LEFT('???????????????_12345678.dat', 4); %fncSTR_REVERSE('???????????????_12345678.dat'); %fncSTR_MID('???????????????_12345678.dat',6,6); */ %fncSTR_LEFT(%fncSTR_RIGHT('???????????????_12345678.dat', 12), 8); %fncSTR_RIGHT('???????????????_12345678.dat', 12); %fncSTR_LEFT("&return.", 8);
... View more