BookmarkSubscribeRSS Feed

As per https://communities.sas.com/t5/SAS-Programming/Duplicating-dataset-using-PROC-DATASETS-in-same-libra... 

 

This is the usage:

 

%let tdy = %sysfunc(today()) ;
%let tdyymd = %sysfunc(putn(&tdy,yymmddn8.)) ;
/* Backup latest with datastamp */
proc datasets lib=logdata nolist mt=data ;
copy logparse_data logparse_data_&tdyymd ;
copy logparse_hdrs logparse_hdrs_&tdyymd ;
quit ;

 

For now, I can use 2 data steps:

 

data logdata.logparse_data_&tdyymd ; set logdata.logparse_data ; run ;
data logdata.logparse_hdrs_&tdyymd ; set logdata.logparse_hdrs ; run ;

 

2 Comments
DianeOlson
SAS Employee

Hi, acfarrer.

 

I'm the developer supporting PROC DATASETS, COPY and APPEND. Thanks for your idea! I wrote a paper that will hopefully be of use to you: https://support.sas.com/resources/papers/proceedings11/084-2011.pdf

In that paper, the section entitled CREATE A CLONE IN THE SAME LIBRARY may be of interest.

 

I noticed that in the linked thread, someone mentioned they would use the operating system to copy the data set. Using the operating system is not a best practice, and can get you into some difficulties if you have generations, audit trails, indexes, integrity constraints and/or extended attributes.

 

Thanks, and please let me know if you have questions.

Diane Olson

ChrisNZ
Tourmaline | Level 20

@DianeOlson 

The dates will be reset when using proc append  whereas they won't be if  proc copy datacopy  or  OS copy  are used.

That's a major difference.

modify dtc= can overcome this in certain cases, at the cost of extra coding, but that's yet another hurdle.

An OS copy will conserve all the dates.

 

proc copy  would be the best placed to duplicate data sets as is. So this suggestion is very relevant imho.