BookmarkSubscribeRSS Feed
Ronein
Meteorite | Level 14

Hello

Let's say that I want to Rename data set tbl1 (in work library) into tbl2 (in work library) then the code will be :

proc datasets library=WORK;
change tbl1=tbl2 ;
run;

Let's say that I want to Rename data set tbl1 (in permanent library R_R) into tbl2 (in permanent library R_R) then the code will be :

proc datasets library=R_R;
change tbl1=tbl2 ;
run;

My question:

Let's say that I want to COPY
data set tbl1 (in WORK library) into tbl1 (in permanent library R_R)  - what is the code to do it?

Please note that the data set is very big(25 million rows and 20 columns)

and running  the following code will be too heavy and not efficient

DATA R_R.tbl1;
SET WORK.tbl1;
Run;
proc delete data=WORK.tbl1;Run;

 

 

6 REPLIES 6
Kurt_Bremser
Super User

Unless your WORK and the permanent library are on the same physical disk (and you use an operating system which allows multiple links), you have to copy the whole file, either through a DATA step or the FCOPY function.

 

Instead of copying from WORK to anywhere else, change the final step which creates the dataset so that it is created in the permanent library in the first place.

Ronein
Meteorite | Level 14
Copy throught data step you mean to this code?
DATA R_R.tbl1;
SET WORK.tbl1;
Run;
PaigeMiller
Diamond | Level 26

PROC COPY works better than a DATA step.

 

 

--
Paige Miller
Ronein
Meteorite | Level 14

Let's say that R_R library is in this path

/usr/local/SAS/SASUsers/LabRet/Credit_Scoring_Users/R_R

What is the FCOPY function code that is needed here?

Kurt_Bremser
Super User
data _null_;
rc = filename("source",pathname("work")!!"/tbl1.sas7bdat",,"recfm=n");
rc = filename("target","/usr/local/SAS/SASUsers/LabRet/Credit_Scoring_Users/R_R/tbl1.sas7bdat",,"recfm=n");
rc = fcopy("source","target");
run;

If you have XCMD enabled, you can use the UNIX system's cp or mv command; if mv finds that both locations are on the same physical filesystem, it will simply create a new directory entry and remove the old one, meaning the whole process will finish in next to no time.

Reeza
Super User
proc copy in=work out=r_r;

select tbl1;

run;

 

 

 

sas-innovate-wordmark-2025-midnight.png

Register Today!

Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.


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
  • 6 replies
  • 1302 views
  • 3 likes
  • 4 in conversation