Hi, I'm looking to create a substr of a variable that is of an uncertain length. The character variable I'm looking at in particular always starts with a number followed by a category, BUT the number and categories vary in length etc.
In this case you might have better luck with the COMPRESS function. If you're not familiar with it, I strongly urge you to read the SAS documentation on it - it's quite a powerful function, which can allow you to keep or drop certain characters or types of characters (e.g. alphabetic characters, numbers). This step below will create what you need for this sample.
number = compress(var1,,'dk');
Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.
If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website.