I did move lib1.ds1 to lib2.ds2 this way, but it had new date information,
both within SAS and Windows. And it wasn't the rename operation that
changed the date information, because I tried running the copy and change
separately, and the date information was changed only by the copy
command. Should the datecopy option do what I wanted it to do? If not,
is there a SAS-specific way to do this (rather than using operating system specific commands)?
Also, I was successful using the datecopy option to preserve the original date of a copied file (on SAS 9.1.3 SP4, Windows XP) -- the processing was successful with copying SASHELP.class to WORK (with datecopy but not move), and then again COPY from lib1 to lib2 with options move and datecopy. However, a new proc datasets was needed to effect the "change" against the lib2 data library - you had lib=lib1 coded though (all functions attempted in a single proc datasets, which would not work.
Hi Scott. Thank you for the follow-up. I didn't understand your description of what you did. Could you please show me your actual code that preserved the original date information after a move and rename (change)?
Just re-tested with the code below (very similar to your code, excepting using SASHELP.CLASS) and the SAS-reported (not Windows) date information (found in PROC CONTENTS member level info) reflects the original SASHELP.CLASS information, as expected (SAS 9.1.3 SP4, Windows):
libname lib1 'c:\temp\sas';
libname lib2 'c:\temp\sas\other';
* start with empty SAS data library references. ;
proc datasets kill nolist lib=lib1;
proc datasets kill nolist lib=lib2;
proc datasets nolist library=lib2;
* copy the SAS sample member. ;
copy datecopy in=sashelp out=lib1;
* CONTENTS will verify the CREATED/MODIFIED date. ;
* now COPY (move) and generate CONTENTS. ;
copy in=lib1 out=lib2 move datecopy;
the "Last Modified" entry in the log (and "Date Modified" entry in Windows Explorer) probably will be more recent than the "Last Modified" entry in the contents output listing. I see that you remarked on this fact in the preface to your code.
So, is there a way to preserve the Windows date information through SAS itself, or does that require the use of operating system specific commands (issued, e.g., via the "X" statement)?
Thank you for responding. Yes, you caught an error in my transcription. I actually did use "change" rather than "rename" in my code, and I didn't get an error message; the move and rename (well, change) worked perfectly, but it didn't preserve the date of the original file, which is what I'd like to do, if possible. So the correct move and rename code is:
but the datecopy option, which is described as follows in the online doc:
"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."
appears to have no effect. I think that last sentence in the description is an admission that the datecopy option isn't designed to do what I wanted. But then I don't even understand what it's good for. There is a remark in the doc that the date can be manually altered using the DTC= option on the MODIFY statement, so maybe I have to see if I can capture the original date info and then reassign it after the move. Honestly, that seems unnecessarily complicated to me, but I'll see if I can get it to work.