BookmarkSubscribeRSS Feed
cloverhorizon
Calcite | Level 5

I am creating a series of if/then statements to assign a large number of various ICD10 codes to a few specific groups in a new variable. This has been going fine until I noticed I have hundreds of individual values to put in my "in: ('a','b')" parentheses for one particular value of this new variable. These values all end in 1 of 6 digits, but go from the low 300's up through the 800's. example:

V324,V325,V326,V327,V328,V329

V334,V335,V336,V337,V338,V339

V344,V345,V346,V347,V348,V349

 

My question is, is there some character I can insert to represent any value? So that I could put something like "in: ('V3*4', 'V3*5','V3*6',)" etc? Or some way to not manually enter these hundreds of codes? I can't just use 'V32' because these values don't include V320, V321, etc. Thank you!

 

1 REPLY 1
ChrisNZ
Tourmaline | Level 20

> something like "in: ('V3*4', 'V3*5','V3*6',)" 

Like this?

if prxmatch('/\AV3\d[456]\Z/',trim(VAR)) then C=1;

\A  = start of string

V3

\d = digit

4 or 5 or 6

\Z = end of string

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 1 reply
  • 605 views
  • 0 likes
  • 2 in conversation