BookmarkSubscribeRSS Feed

Change Encoding using SAS Enterprise Guide/Windowing Environment/SAS Studio

Started ‎10-18-2019 by
Modified ‎10-20-2019 by
Views 27,322

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


A. Changing the Encoding of the Session


When I run the below code in SAS Enterprise Guide, then the log show "ENCODING=WLATIN1". See: Below Image


       proc options option=encoding;



       %PUT %SYSFUNC(getOption(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:

  1. Go to the link:  C:\Program Files\SASHome_foundation\SASFoundation\9.4\nls

          There should be a configuration file sasv9.cfg in both "en" and "u8" folders.


  1. There is a file sasv9.cfg on the location: C:\Program Files\SASHome_foundation\SASFoundation\9.4

          Open it in notepad. Here you will find the config;

          -config "C:\Program Files\SASHome_foundation\SASFoundation\9.4\nls\en\sasv9.cfg"


  1. Make a small change in it. Just replace "en" with "u8" and Save.

          -config "C:\Program Files\SASHome_foundation\SASFoundation\9.4\nls\u8\sasv9.cfg"


  1. Open a new session of SAS Enterprise Guide and run the below code again.

          proc options option=encoding;



          %PUT %SYSFUNC(getOption(ENCODING));


     5. Now the Encoding of your system will change from WLATIN1 to UTF - 8.


B. Changing the Encoding of the Library


   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;


            Encoding9.PNG                                 Encoding10.PNG


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;


           Encoding12.PNG                               Encoding10.PNG


Thus, we can see that the encoding of all the data set has been changed into UTF-8.



C. Changing the Encoding of the SAS Dataset


   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.


     %LET DSID=%SYSFUNC(open(sashelp.class,i));





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.


       data work.class;

       set sashelp.class;


       proc contents data=work.class;run;


       %LET DSID=%SYSFUNC(open(work.class,i));





3. Encoding change to UTF-8:

      data work.class_2(encoding='utf-8');

      set sashelp.class;


      proc contents data=work.class_2;run;


      %LET DSID=%SYSFUNC(open(work.class_2,i));





4. Encoding change to LATIN1:


     data work.class_3(encoding='Latin1');

     set sashelp.class;


     proc contents data=work.class_3;run;


     %LET DSID=%SYSFUNC(open(work.class_3,i));







Thank you for an informative article.  A question, is SAS dataset readable by SAS code or via EG/Explorer/program wise regardless of its encoding?  For example, a SAS default setting is WLATIN1 and some datasets are in LATIN or UTF-8, is that still viewable?

Version history
Last update:
‎10-20-2019 11:59 PM
Updated by:




The early bird rate has been extended! Register by March 18 for just $695 - $100 off the standard rate.


Check out the agenda and get ready for a jam-packed event featuring workshops, super demos, breakout sessions, roundtables, inspiring keynotes and incredible networking events. 


Register now!

Free course: Data Literacy Essentials

Data Literacy is for all, even absolute beginners. Jump on board with this free e-learning  and boost your career prospects.

Get Started

Article Tags