I tried it out with SAS 9.1 and there is a special thing with the
compare-function. If the first argument preceeds the second one in sort
sequence, the result is negative. So if you want the position of the
first-not-equal char, use something like:
8 data a;
13 put _all_;
a=1234567hjgsaajsdhj b=12345kdljnklfdlk x=6 res=67hjgsaajsdhj _ERROR_=0 _N_=1
note the ABS function to ignore the negative sign.
On Mon, 14 Feb 2005 08:58:51 -0800, Armin Bauerbach
>Here is a nice answer from a SAS employee I got off line. Since I
>havn't installed V9 yet I am not able to check it out.
>In SAS 9, you can use the COMPARE function to find the leftmost
>position at which two strings differ. Then take the substring up
>to but not including that position using the SUBSTRN function.
>Warren S. Sarle SAS Institute Inc. The opinions expressed here
>email@example.com SAS Campus Drive are mine and not
>(919) 677-8000 Cary, NC 27513, USA those of SAS Institute.