1. Use FINDW() to find the first STOP.
2. Use FINDW() again to find the second STOP - use the starting position from the first answer as a parameter to the second call to find the start of the second STOP
3. Use SUBSTR() to substring the string to the desired length - from 1 to the answer from step 2.
Documentation for FINDW.
https://documentation.sas.com/?cdcId=pgmsascdc&cdcVersion=9.4_3.5&docsetId=lefunctionsref&docsetTarg...If you're having issues post your code something as follows:
data have;
string = ":20:catclimbedthetree:STOP:dogranaftercat:STOP:catwasinthehouse:-";
firstSTOP = findw( .... ); * you need to fill in the appropriate parameters;
secondStop = findw(string, ...., firstStop); * you need to fill in the appropriate parameters;
want = substr(1, secondSTop);
run;