Dunn, Toby wrote:
> If your anything like myself you hate writing abunch of code for
> simple problems.
> Try the following:
> data _null_;
> a = "ABCcccABCdddABCfff";
> n = (length(a) - length(compress(a,'ABC'))) / 3;
> put n=;
> Short and too the point and gets the right answer.
In only extremely limited situations...
6 data null;
7 a = "CBA BACH";
8 n = (length(a) - length(compress(a,'ABC'))) / 3;
9 put n=;
Oops! Tranwrd() is better
Here is a real goofy way, using macro. Not for production use.
%macro increment (mvar);
%let &mvar = %eval(&&&mvar + 1);
string = "CBA BACH ABC foo ABC";
excerpt = 'ABC';
length s $200;
call symput ('x','0');
s = quote(tranwrd (string, excerpt, '%increment(x)'));
s = resolve (s);
n = symget('x');
Richard A. DeVenezia