I'm downloading (with a proc download in SAS) a dataset from a server with wlatin1 encoding to a server with UTF-8 encoding.
I've got the error
ERROR: Some character data was lost during transcoding in the data set
libref.datasetname. Either the data contains characters that are not
representable in the new encoding or truncation occurred during transcoding.
I tried setting inencoding='utf8' or inencoding='asciiany' on the input dataset but it doesn't work (maybe because the wlatin1 server has SAS 9.3 whereas the UTF-8 server has SAS 9.4).
Rewriting the file like in the following code (and then doing the proc download of myoutput) works, but I was wondering if there is a more elegant way to do the same thing.
data myoutput;
set pathin.myinput;
/*Translittera la I accentata con I normale*/
des_nome = tranwrd(des_nome,'CD'x,'I');
des_nome = tranwrd(des_nome,'ED'x,'i');
/*Translittera la A accentata con A normale*/
des_nome = tranwrd(des_nome,'C1'x,'A');
des_nome = tranwrd(des_nome,'E1'x,'a');
/*Translittera la E accentata con E normale*/
des_nome = tranwrd(des_nome,'C9'x,'E');
des_nome = tranwrd(des_nome,'E9'x,'e');
/*Translittera la O accentata con O normale*/
des_nome = tranwrd(des_nome,'D2'x,'O');
des_nome = tranwrd(des_nome,'D3'x,'O');
des_nome = tranwrd(des_nome,'D6'x,'O');
des_nome = tranwrd(des_nome,'F3'x,'o');
/*Translittera la U accentata con U normale*/
des_nome = tranwrd(des_nome,'DC'x,'U');
des_nome = tranwrd(des_nome,'F9'x,'u');
/*Translittera la Y accentata con Y normale*/
des_nome = tranwrd(des_nome,'DD'x,'Y');
des_nome = tranwrd(des_nome,'FD'x,'y');
/*Translittera accenti strani con '*/
des_nome = tranwrd(des_nome,'B4'x,"'");
/*Translittera simboli strani con spazi*/
des_nome = tranwrd(des_nome,'A7'x,' '); /* § nel NOME */
des_nome = tranwrd(des_nome,'A3'x,' '); /* £ nel NOME */
cod_cap_res = tranwrd(cod_cap_res,'A3'x,' '); /* £ nel CAP */
run;