Here is the simplest solution I could muster:
DATA LIST FREE / str (a10).
STRING #Prev (A1).
+ DO IF CHAR.SUBSTR(str,#cur,1) EQ #Prev.
+ COMPUTE str=CONCAT(CHAR.SUBSTR(str,1,#cur-1),CHAR.SUBSTR(str,#cur+1) ).
+ COMPUTE #cur=#cur+1.
+ END IF.
+ COMPUTE #Prev=CHAR.SUBSTR(str,#cur-1).
END LOOP IF #cur GT CHAR.LENGTH(str).
If this doesn't do what you want then you need to elaborate and illustrate with an example of your intended result.
On Wednesday, September 21, 2016 at 2:05:37 PM UTC-4, Rich Ulrich wrote:
> On Wed, 21 Sep 2016 07:51:37 -0700 (PDT), email@example.com
> >I'm trying to find out how to detect repeated characters (such as "aaaaaa", "gggggg", "ZZZ", ...)
> >Anyone has got an idea how to do it?
> Obviously, you have to have a loop in which you pick up each
> character and compare it to something - first character or
> previous character, it seems - until you reach the end of
> the non-blank part of the string. Consider LTRIM? RTRIM?
> If you only want to know that some character is repeated,
> somewhere, you compare each to the previous, and quit
> once there is a single match.
> What you do in detail depends on what you want to know and
> Rich Ulrich