BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Shmuel
Garnet | Level 18

While trying to contribute to https://communities.sas.com/t5/SAS-Programming/Encoding-from-LATIN1-to-UTF8-w-o-changing-files-time-... I proposed to make a combination of linux copy (cp) with -p option to preserve the original attributes, and create a view that will translate the encoding into the required one.

 

Later I used SAS-UE to test my proposed code and found that it doesn't work as expected. Code and log are:

 

73         data work.class (encoding='Latin1') / view=work.class;
 74          set sashelp.class;
 75         run;
 
 ERROR: The ENCODING= data set option is not supported for DATA step views.
 NOTE: View not saved due to errors.
 NOTE: The SAS System stopped processing this step because of errors.

It could be worthful to enable encoding, as translation tool, to views without need to copy the whole data thus saving disk space.

 

 

 

1 ACCEPTED SOLUTION
5 REPLIES 5
Tom
Super User Tom
Super User

I don't understand why that would be needed.

1     %put %sysfunc(getoption(encoding));
UTF-8
2     proc contents data=sashelp.class; run;

NOTE: PROCEDURE CONTENTS used (Total process time):
      real time           0.39 seconds
      cpu time            0.04 seconds


3     data class / view=class ;
4       set sashelp.class;
5     run;

NOTE: DATA STEP view saved on file WORK.CLASS.
NOTE: A stored DATA STEP view cannot run under a different operating system.
NOTE: DATA statement used (Total process time):
      real time           0.13 seconds
      cpu time            0.01 seconds


6
7     data class_copy;
8      set class;
9     run;

NOTE: View WORK.CLASS.VIEW used (Total process time):
      real time           0.09 seconds
      cpu time            0.01 seconds

NOTE: There were 19 observations read from the data set SASHELP.CLASS.
NOTE: There were 19 observations read from the data set WORK.CLASS.
NOTE: The data set WORK.CLASS_COPY has 19 observations and 5 variables.
NOTE: DATA statement used (Total process time):
      real time           0.15 seconds
      cpu time            0.04 seconds


10
11    proc contents data=class_copy;
12    run;

NOTE: PROCEDURE CONTENTS used (Total process time):
      real time           0.01 seconds
      cpu time            0.00 seconds

The resulting CLASS_COPY dataset is using the UTF-8 encoding.

Shmuel
Garnet | Level 18

@Tom, you are running in sas environment already defined with encodig=utf-8.

The problem arised when a mass of datasets were created with encoding=Latin1 but need be

converted to encoding=utf-8.

 

Tom
Super User Tom
Super User

@Shmuel wrote:

@Tom, you are running in sas environment already defined with encodig=utf-8.

The problem arised when a mass of datasets were created with encoding=Latin1 but need be

converted to encoding=utf-8.

 


So do the conversion in a session using UTF-8 encoding.

sas-innovate-white.png

Missed SAS Innovate in Orlando?

Catch the best of SAS Innovate 2025 — anytime, anywhere. Stream powerful keynotes, real-world demos, and game-changing insights from the world’s leading data and AI minds.

 

Register now

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
  • 5 replies
  • 1172 views
  • 0 likes
  • 3 in conversation