Hi,
Annually, I process a large dataset with 7 name fields; some of the names have accented characters, e.g., Aarón. I posted here about 4 years ago and found the solution (thank you all!) of using the translate function to replace the accented characters with “normal” letters:
array seven {7} $ mfirsta mmiddlea mlasta bfirsta bmiddlea blasta dlasta;
array eight {7} $ mfirst mmiddle mlast bfirst bmiddle blast dlast;
do k=1 to dim(seven);
eight{k}=upcase(translate(seven{k},"aaaaaaceeeeiiiiooooouuuun","àáâäãåçéèêëîïìíôòóõöùúûüñ"));
end;
I did not run the program last year; this year it won’t work. When SAS (this year is SAS 9; not sure what it was before) reads in the data it replaces the accented characters with little “boxes” before the translate code can take effect. Searching the community help forums I found the tranwrd function, which helped but as a previous poster noted replaced the accented characters with a blank space. Per other suggestions, I converted the raw data file to utf8, and eventually found that the following works:
array seven {7} $ mfirsta mmiddlea mlasta bfirsta bmiddlea blasta dlasta;
array eight {7} $ mfirst mmiddle mlast bfirst bmiddle blast dlast;
...
array eighteen {7} $ mfirst mmiddle mlast bfirst bmiddle blast dlast;
array nineteen {7} $ mfirst mmiddle mlast bfirst bmiddle blast dlast;
do k=1 to dim(seven);
eight{k}=tranwrd(seven{k},"à","a");
nine{k}=tranwrd(eight{k},"á","a");
...
seventeen{k}=tranwrd(sixteen{k},"ù","u");
eighteen{k}=tranwrd(seventeen{k},"ú","u");
nineteen{k}=tranwrd(eighteen{k},"ñ","n");
end;
But, this is pretty clunky, and only covers half of the 25 accented characters in the original code. There must be a more streamlined method?
Thanks.
... View more