In this Article, I am going to describe three ways to change the Encoding using SAS Enterprise Guide.
A. How to change the Encoding of the Session
B. How to change the Encoding of Library
C. How to change the Encoding of Dataset
When I run the below code in SAS Enterprise Guide, then the log show "ENCODING=WLATIN1". See: Below Image
proc options option=encoding;
Now, to change the Encoding from WLATIN1 to UTF-8, We have to change in the configuration file.
See: Below Image (Expected Result)
To get this result follow the steps:
There should be a configuration file sasv9.cfg in both "en" and "u8" folders.
Open it in notepad. Here you will find the config;
-config "C:\Program Files\SASHome_foundation\SASFoundation\9.4\nls\en\sasv9.cfg"
-config "C:\Program Files\SASHome_foundation\SASFoundation\9.4\nls\u8\sasv9.cfg"
proc options option=encoding;
5. Now the Encoding of your system will change from WLATIN1 to UTF - 8.
To change the encoding of entire library, I will explain the process considering an example. Suppose there are a lot of dataset in a library and someone want to change the particular encoding (like UTF-8, LATIN1, WLATIN1 etc.) of all the datasets, So, instead of changing encoding one by one of datasets change the encoding of the library. Now the encoding of all the datasets become same.
There are two datasets class_data_1 and class_data_2 with different encoding "wlatin1" and "utf-8" respectively. Both the datasets are in library "lib".
proc contents data=lib._all_; run;
Now run the below code to change the encoding of library. Notice that, there should be same path for inlib and lib library.
libname inlib cvp 'Path_1';
libname outlib 'Path_2' outencoding='UTF-8';
proc copy noclone in=inlib out=outlib;
proc contents data=outlib._all_; run;
Thus, we can see that the encoding of all the data set has been changed into UTF-8.
Here, we will see the default encoding of dataset and change of encoding into "WLATIN1 Western (Windows)", "UTF-8 Unicode" and "LATIN1 Western (ISO)".
1. Default Encoding of Dataset:
To check the default encoding of base data, run the below code in SAS Enterprise Guide or Windowing Environment or SAS Studio.
So, we can see that the default encoding of class dataset in sashelp library is "US-ASCII".
2. Encoding change from default:
When someone make any change in data or save in other library then the encoding become default according to your system configuration.
proc contents data=work.class;run;
3. Encoding change to UTF-8:
proc contents data=work.class_2;run;
4. Encoding change to LATIN1:
proc contents data=work.class_3;run;
Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.
If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website.
Data Literacy is for all, even absolute beginners. Jump on board with this free e-learning and boost your career prospects.