It might be a good idea to provide some example data, the basic rules (not code when you don't have code that works) and an example of the output for the example data.
It may be that you need more parentheses for grouping related concepts.
https://brilliant.org/wiki/de-morgans-laws/ may help a bit to work out some details of OR , AND combinations of logic.
This "trick" of converting your values to numeric, assuming all of the values you need to test follow the 5 digit examples, may help simplify the code:
data have; input x $; datalines; 99123 99124 99125 99127 99234 99235 99236 99237 ; data example; set have; where input(x,f5.) not in (99123:99125 99234:99236); run;
The IN operator will accept numeric ranges, indicated by the : between two integers to select integer values and might considerably reduce the amount of code needed. The above code excludes values and is what I think could replace
(cpt not between '99123' and '99125') and (cpt not between '99234' and '99236')
Personally I will go out my way to do any comparisons with text values and ranges as they so seldom work nicely. If every single value has the exact same number of characters then maybe.