Assume I have the following data stored in a SAS table:
Actual | Desired |
US1234 | 1234 |
13 | 13 |
14567 | 14567 |
US3345 | 3345 |
What I would like to do is to check each row, if the first two letters are "US" then I would like to remove those letters. If the first two letters are not "US" I want to keep the row as it is.
Any idea on how to do this?
Try this:
if actual=:'US' then desired=substr(actual,3);
else desired=actual;
Maybe COMPRESS works with your data as well as the solution I provided, but COMPRESS will do things to your data that you didn't ask for, such as remove US from anywhere in the string (you didn't ask for that, you asked only for beginning of the string) and it will remove U from anywhere and it will remove S from anywhere. Again, this may work fine on your data, but I point this out for anyone else reading along who may have different data.
Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.
Register today!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.
Select SAS Training centers are offering in-person courses. View upcoming courses for: