BookmarkSubscribeRSS Feed
shoin
Lapis Lazuli | Level 10

Due to audit requirements, need to convert Latin1 encoded files to utf8 however, due to requirements need to preserver time stamp attributes.  Is it possible?  (source and target both Linux)

 

Thank you in advance,

 

S

 

 

9 REPLIES 9
Shmuel
Garnet | Level 18

1) What kind of files you need in utf8 ?

2) Check the documentation about data/file option: encoding='utf8'.

shoin
Lapis Lazuli | Level 10

TY for your time.  The encoding portion and how to change from latin1 to utf8 at system level and using proc copy is known.  The only issue is that there are large # of files that could not have their timestamp attribute change and while doing proc copy with datecopy option is also not saving the original date and time of the file.  

Shmuel
Garnet | Level 18

@shoin wrote:

TY for your time.  The encoding portion and how to change from latin1 to utf8 at system level and using proc copy is known.  The only issue is that there are large # of files that could not have their timestamp attribute change and while doing proc copy with datecopy option is also not saving the original date and time of the file.  


I understand that you talk about sas datasets. 

Please check, does a view satisfy the requirements? so encoding translation is done while reading the original file and the same time saves disk storage.

 

In case that you must have a copy of the file in different libraries, please check is there a method to do it by linux command.

See for example next link: https://askubuntu.com/questions/1040885/copy-file-and-keep-same-timestamp-of-original-file  

Shmuel
Garnet | Level 18

@shoin wrote:

TY for your time.  The encoding portion and how to change from latin1 to utf8 at system level and using proc copy is known.  The only issue is that there are large # of files that could not have their timestamp attribute change and while doing proc copy with datecopy option is also not saving the original date and time of the file.  


Pay attention to bold note in PROC COPY documentatiom:

 

  "DATECOPY

copies the SAS internal date and time when the SAS file was created and the date and time when it was last modified to the resulting copy of the file. Note that the operating environment date and time are not preserved.
Restrictions:DATECOPY cannot be used with encrypted files or catalogs.

DATECOPY can be used only when the resulting SAS file uses the V8 or V9 engine.

Tips:You can alter the file creation date and time with the DTC= option in the MODIFY statement. See MODIFY statement.

If the file that you are copying has attributes that require additional processing, the last modified date is changed to the current date. For example, when you copy a data set that has an index, the index must be rebuilt, and the last modified date changes to the current date. Other attributes that require additional processing and that could affect the last modified date include integrity constraints and a sort indicator."

 

It seems that altering the encoding, made an aditional process, therefore DATECOPY did not work and you got the current date.

 

I hoped that view could serve to translate encoding and was disapointed while testing the code, as shown in next link:

https://communities.sas.com/t5/SAS-Programming/Disapointing-behaviour-using-ENCODING-option-consider... 

 

Shmuel
Garnet | Level 18
PAY ATTENTION TO @Tom's proposal to run proc copy in a separate session defined ahead with encoding=utf-8. Try it.
Reeza
Super User
You're changing the file so the metadata attributes will change AFAIK. If you're referring to elements within the file that's a different issue.
shoin
Lapis Lazuli | Level 10

Hi, not an efficient solution for a large # of files.  TY though.

Kurt_Bremser
Super User

@shoin wrote:

Hi, not an efficient solution for a large # of files.  TY though.


It's as easy to automate as the encoding conversion. Retrieve the date, do the conversion, set the date, all within the same loop.

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 9 replies
  • 2864 views
  • 2 likes
  • 4 in conversation