Thank you for the help. In the end I used the CVP and some other thing. I'm adding my code for others to steal! %macro fixEncoding(fromLib);
%macro dummy();%mend dummy; *Fix syntax highlighting in the macro. Stupid but it works!;
options dlcreatedir; *To automatically create the sub folder in the TempLib.;
*Get the folder path from the library that we are going to copy from as well as the work libary. Keep the temporary files contained.;
libname INLIB cvp "%sysfunc(pathname(&fromLib))" CVPMULTIPLIER=2;
libname TEMPLIB "%sysfunc(pathname(WORK))/temp" outencoding='UTF-8';
*Remove all the tables if there are any in the TempLibary;
%let tablesToKill=;
proc sql noprint ;
select memname into : tablesToKill separated by " "
from dictionary.tables
where upcase(libname) = upcase("TEMPLIB");
quit;
*I do not like warnings in the log, if the TempLibary is empty and we try to remove all tables in there, we will get a warning.;
%if "&tablesToKill" ne "" %then %do;
proc datasets kill lib=TEMPLIB nodetails nolist ;
run;
%end;
*Copy only the tables from the libary to our TempLibrary, but with the correct encoding and if needed longer string variables.;
%put INFO: About to fix the encoding and save the data sets from &fromLib to templib.;
proc copy noclone in=&fromLib out=TEMPLIB memtype=data;
run;
*Replace the data sets in the original library with the fixed data sets.;
%put INFO: Going to copy the data sets back to &fromLib;
proc copy in=TEMPLIB out=&fromLib ;
run;
%put INFO: Checking that we do not get any comments in the log about;
%put INFO- Data file X.DATA is in a format that is native to another host, or the file encoding does;
%put INFO- not match the session encoding. Cross Environment Data Access will be used, which might require additional CPU resources and ;
%put INFO- might reduce performance.;
proc sql noprint ;
create table all_tables as
select libname,
memname as SAS_table_name label="Table name",
memlabel as table_label label="Table lable",
nobs as no_of_rows label="Number of observations in the table" format=nlnum15.,
nvar as no_of_vars label="Number of variables in the table",
crdate as creation_dt_n label="Creation date" format=datetime19.,
modate as modification_dt_n label="Modification date" format=datetime19.
from dictionary.tables
where upcase(libname) = upcase ("&fromLib");
quit;
%mend fixEncoding;
%fixEncoding(COMP);
... View more