Hi,
How should I handle below special charcters?
’ replaced by '
• by space
´ replace by '
data abc;
y="The Subject’s status was not changed";output;
y="The Subject has - •6 point";output;
y="The subject didn´t capture photo";output;
run;
data xyz;
set abc ;
y1=tranwrd (y, "’" , "'");
y1=tranwrd (y, "•" ,"");
y1=tranwrd (y, "´" , "'");
run;
data xyz;
set abc ;
y1=tranwrd (y, "’" , "'");
y1=tranwrd (y, "•" ,"");
y1=tranwrd (y, "´" , "'");
run;
Since you always create y1 anew from y, only the last result will show up in your output, overwriting the results of the previous translations. Change this to
data xyz;
set abc ;
y1=tranwrd (y, "’" , "'");
y1=tranwrd (y1, "•" ,"");
y1=tranwrd (y1, "´" , "'");
run;
Yes this is not working, do you have any other solution for this senerio.
You seem to have an encoding issue. In your post you have two different sets of characters. One set in the description of the problem and different characters in the code.
So which ones to you have in your actual file? Look at the Hexadecimal representation of the strings to see what is actually in the file.
E28099 ’ E280A2 • C2B4 ´ 92 ’ 95 • B4 ´
What encoding is your SAS session using? Check the value of the SYSENCODING macro variable. What encoding is the dataset that has values using? Check PROC CONTENTS output for the dataset.
You can use hexadecimal constants in your SAS code to make the code more portable.
Run the right code for the encoding that is in the character variable Y.
* UTF-8 codes ;
y1=tranwrd(y, 'E28099'x , "'");
y1=tranwrd(y1,'E280A2'x ," ");
y1=tranwrd(y1, 'C2B4'x , "'");
* WLATIN1 code ;
y1=translate(y,"' '",'929584'x);
Don’t miss the livestream kicking off May 7. It’s free. It’s easy. And it’s the best seat in the house.
Join us virtually with our complimentary SAS Innovate Digital Pass. Watch live or on-demand in multiple languages, with translations available to help you get the most out of every session.
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.
Ready to level-up your skills? Choose your own adventure.