BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
data_null__
Jade | Level 19

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. 🙂

 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
yabwon
Amethyst | Level 16

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

_______________
Polish SAS Users Group: www.polsug.com and communities.sas.com/polsug

"SAS Packages: the way to share" at SGF2020 Proceedings (the latest version), GitHub Repository, and YouTube Video.
Hands-on-Workshop: "Share your code with SAS Packages"
"My First SAS Package: A How-To" at SGF2021 Proceedings

SAS Ballot Ideas: one: SPF in SAS, two, and three
SAS Documentation



View solution in original post

8 REPLIES 8
yabwon
Amethyst | Level 16

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

_______________
Polish SAS Users Group: www.polsug.com and communities.sas.com/polsug

"SAS Packages: the way to share" at SGF2020 Proceedings (the latest version), GitHub Repository, and YouTube Video.
Hands-on-Workshop: "Share your code with SAS Packages"
"My First SAS Package: A How-To" at SGF2021 Proceedings

SAS Ballot Ideas: one: SPF in SAS, two, and three
SAS Documentation



quickbluefish
Barite | Level 11
...never seen that dlcreatedir option!
yabwon
Amethyst | Level 16

it's pretty handy one 🙂

_______________
Polish SAS Users Group: www.polsug.com and communities.sas.com/polsug

"SAS Packages: the way to share" at SGF2020 Proceedings (the latest version), GitHub Repository, and YouTube Video.
Hands-on-Workshop: "Share your code with SAS Packages"
"My First SAS Package: A How-To" at SGF2021 Proceedings

SAS Ballot Ideas: one: SPF in SAS, two, and three
SAS Documentation



ChrisHemedinger
Community Manager

It's an oldie-but-a-goodie, and you can even go deep with it. See when I first wrote about it here.

SAS For Dummies 3rd Edition! Check out the new edition, covering SAS 9.4, SAS Viya, and all of the modern ways to use SAS!
quickbluefish
Barite | Level 11
love the SEP concept!
data_null__
Jade | Level 19

@quickbluefish wrote:
...never seen that dlcreatedir option!

That is a great feature.  I can never remember how to spell it.  DataLibraryCreateDirectory

data_null__
Jade | Level 19

@yabwon thanks so much this worked great.  I did have to use INENCODING=wlatin1 on the IN= library.

Ksharp
Super User

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)

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 8 replies
  • 198 views
  • 10 likes
  • 5 in conversation