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.
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.
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.