Is the variable character or numeric?
This can be important as when you use character functions, such as the PRX functions, then SAS does an automatic conversion from the numeric to character that likely is not going to result in the actual desired character string before "counting" or matching.
If the variable is actually character than the LENGTH function will return the number of characters though may count any leading spaces. So actual examples of your data and complete code plus what you expect might be helpful in diagnosing what is going on.
... View more