I want to correct the encoding for all members of a data library.
proc datasets lib=orig;
modify ae / correctencoding=wlatin1; /* or windows-1252 */
quit;
I know I can use codegen to do this task. Is there a way this can be done using COPY perhaps? Modify _ALL_ does not work. 🙂
John, how about:
options dlcreatedir;
libname in "R:\in";
libname out "R:\out" outencoding=wlatin1;
data in.a in.b in.c;
set sashelp.class;
run;
proc copy NOCLONE in=in out=out;
run;
proc contents data=out.b;
run;
Bart
John, how about:
options dlcreatedir;
libname in "R:\in";
libname out "R:\out" outencoding=wlatin1;
data in.a in.b in.c;
set sashelp.class;
run;
proc copy NOCLONE in=in out=out;
run;
proc contents data=out.b;
run;
Bart
it's pretty handy one 🙂
It's an oldie-but-a-goodie, and you can even go deep with it. See when I first wrote about it here.
@quickbluefish wrote:
...never seen that dlcreatedir option!
That is a great feature. I can never remember how to spell it. DataLibraryCreateDirectory
@yabwon thanks so much this worked great. I did have to use INENCODING=wlatin1 on the IN= library.
John.King ,
There is a built-in sas macro to make it happen. This built-in macro can change any encoding into other encoding:
https://go.documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/nlsref/p1g1d26os4w0von1cdfh827foo3r.htm
For example:
Change EUC-CN(your sas session is EUC-CN encoding) into UTF-8:
%let path= C:\temp\原始的SAS数据集\ ;
options validvarname=any;
libname x v9 "&path.";
/*
%COPY_TO_NEW_ENCODING(from_dsname, to_dsname, new_encoding)
*/
%copy_to_new_encoding(x.have, outdata, utf8)
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
Still thinking about your presentation idea? The submission deadline has been extended to Friday, Nov. 14, at 11:59 p.m. ET.
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.