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

When copy data sets from directory RDATA to EDATA, the date have been modified as current date, how I can I keep it as last modified date? 

 

proc datasets library=rdata;
   copy out=edata datecopy CONSTRAINT=yes index=yes;
run;

1 ACCEPTED SOLUTION

Accepted Solutions
PeterClemmensen
Tourmaline | Level 20

This can not be done with PROC DATASETS when the data set you copy is indexed. When you use the DATECOPY Option, the modified and created date are preserved unless some processing on the data set is necessary which it is when the data set is indexed because the procedure has to rebuld the data set.

 

Read the Documentation for the COPY Statement for more information.

 

I'm not sure if there is a workaround, but I don't think it is possible.

View solution in original post

11 REPLIES 11
PeterClemmensen
Tourmaline | Level 20

This can not be done with PROC DATASETS when the data set you copy is indexed. When you use the DATECOPY Option, the modified and created date are preserved unless some processing on the data set is necessary which it is when the data set is indexed because the procedure has to rebuld the data set.

 

Read the Documentation for the COPY Statement for more information.

 

I'm not sure if there is a workaround, but I don't think it is possible.

Chunling
Calcite | Level 5
Thank you very much for your help, even I use index=No, the date also as current date, would you please help to write the code? as I try it many times and always failing, thank you very much!
VDD
Ammonite | Level 13 VDD
Ammonite | Level 13

have you tried to use windows explore to do the copy paste?

 

Chunling
Calcite | Level 5

@VDDWould you please help to provide an example? as I am not familiar with that, thank you very much!

Ksharp
Super User


libname x v9 'c:\temp\';
/*Get the modify datetime of TEST*/
%let dsid=%sysfunc(open(x.test));
%let m_date=%sysfunc(attrn(&dsid,modte),datetime.);
%let dsid=%sysfunc(close(&dsid));
%put &m_date;

proc copy in=x out=work;
select test;
run;

proc datasets library=work nolist nodetails;
   /*change WORK.TEST 's modify time*/
   modify test/dtc="&m_date"dt;
quit;
PeterClemmensen
Tourmaline | Level 20

@Ksharp, wouldn't this modify the created date of the data set only?

Ksharp
Super User

Yeah. You are right. I thought it would be modified date.

Chunling
Calcite | Level 5

@Ksharp  Thank you very much, I haven't test in SAS server as I can't login at home today

Chunling
Calcite | Level 5

@KsharpHello Ksharp, I have try to edit as your guide, but it also doesn't work as one error, even though add the  outrep=WINDOWS_32 after libname, would you please help guide further? thank you very much!

 

ERROR: File EDATA.AE cannot be updated because its encoding does not match the session encoding or the file is in
       a format native to another host, such as WINDOWS_32.

Ksharp
Super User

My code can't change modify time of file, so ignore my post. 

Ksharp
Super User

Could you try to use FCOPY() function in data step  to copy sas tables ?

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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.

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
  • 11 replies
  • 2892 views
  • 0 likes
  • 4 in conversation