In my dataset, I want to display those records containing special character.Also a column should be added containing the list of spl char.
e.g.
data have;
input id string :$100.;
cards;
1 Asthma!I
2 Anaphylexia@#T
3 The Government has called for the immediate release of an Irishman $$$1O
4 He is suffereinΣg from Jaund■ce
5 Film¶city looks go§d
6 The IÉnternational @l¥mpic Committee has moved to cÄlm fears
7 IV.D10W250
8 I fell in river
9 Singapore will add two new subway lines and expand three existing lines
Output should be like this
ID string specialchar
1 Asthma!I !
2 Anaphylexia@#T @#
etc...
: With compress you can specify exactly which characters to either keep or ignore. e.g.:
data have;
informat string $100.;
input id string &;
cards;
1 Asthma!I
2 Anaphylexia@#T
3 The Government has called for the immediate release of an Irishman $$$1O
4 He is suffereinΣg from Jaund■ce
5 Film¶city looks go§d
6 The IÉnternational @l¥mpic Committee has moved to cÄlm fears
7 IV.D10W250
8 I fell in river
9 Singapore will add two new subway lines and expand three existing lines
10 I'll never tell
;
data want;
set have;
specialchar = compress(compress(string,"'.", 'n'));
run;
Using the compress I managed to retrieve the special characters, but unfortunately the 'É' and 'Ä' are not considered as special but rather as alpha...
data want;
set have;
specialchar = compress(compress(string, , 'a'));
run;
: With compress you can specify exactly which characters to either keep or ignore. e.g.:
data have;
informat string $100.;
input id string &;
cards;
1 Asthma!I
2 Anaphylexia@#T
3 The Government has called for the immediate release of an Irishman $$$1O
4 He is suffereinΣg from Jaund■ce
5 Film¶city looks go§d
6 The IÉnternational @l¥mpic Committee has moved to cÄlm fears
7 IV.D10W250
8 I fell in river
9 Singapore will add two new subway lines and expand three existing lines
10 I'll never tell
;
data want;
set have;
specialchar = compress(compress(string,"'.", 'n'));
run;
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.