Since the original question was posted in 2011, it's assumed that by now SAS®9 has been installed, therefore this solution is written for customers using SAS®9 technology.
.
data a_;
x='abëd34Ý90$#$%a';
new=compress(x,"ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890`~!@#$%^&*()-_=+\|[]{};:',.<>?/ " , "kis");
run;
The COMPRESS function is typically used to remove unwanted characters from a variable, but in this example, the characters to keep are specified.
In the second argument of the COMPRESS function, specify characters that you want to keep in X, and specify in the third argument any modifiers. In this example, the modifiers used are:
'k' keeps the characters in the list instead of removing them.
'i' ignores the case of the characters to be kept or removed.
's' adds space characters (blank, horizontal tab, vertical tab, carriage return, line feed, and form feed) to the list of characters.
Although there are different ways to solve this problem, I chose this approach for simplicity.
Since the original question was posted in 2011, it's assumed that by now SAS®9 has been installed, therefore this solution is written for customers using SAS®9 technology.
.
data a_;
x='abëd34Ý90$#$%a';
new=compress(x,"ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890`~!@#$%^&*()-_=+\|[]{};:',.<>?/ " , "kis");
run;
The COMPRESS function is typically used to remove unwanted characters from a variable, but in this example, the characters to keep are specified.
In the second argument of the COMPRESS function, specify characters that you want to keep in X, and specify in the third argument any modifiers. In this example, the modifiers used are:
'k' keeps the characters in the list instead of removing them.
'i' ignores the case of the characters to be kept or removed.
's' adds space characters (blank, horizontal tab, vertical tab, carriage return, line feed, and form feed) to the list of characters.
Although there are different ways to solve this problem, I chose this approach for simplicity.
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.
Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.