DATA Step, Macro, Functions and more

Renaming a dataset during a proc copy

Accepted Solution Solved
Reply
Frequent Contributor
Posts: 128
Accepted Solution

Renaming a dataset during a proc copy

Hi,

 

I need to move a dataset from one libname to another, but i don't want to use a data/set statement because they can be large and i have no reason to read the observations.

 

But i want to rename the dataset in the new location.  I was using proc copy until the rename issue came up, and i can't find anything online that shows how to do that.

 

proc copy in=kcurr out=knew;
    select k4_29jun16;
run;

 

I want to rename it to just K4 in the knew location.

 

Thanks,

Megan


Accepted Solutions
Solution
‎06-30-2016 10:10 AM
Frequent Contributor
Posts: 128

Re: Renaming a dataset during a proc copy

Well, i have this working.  Anyone know how to get it all done in one step though instead of two?

 

proc copy in=kcurr out=knew;
    select &k4.;
run;
proc datasets library=knew;
    change &k4.=k4;
run;
quit;

View solution in original post


All Replies
Solution
‎06-30-2016 10:10 AM
Frequent Contributor
Posts: 128

Re: Renaming a dataset during a proc copy

Well, i have this working.  Anyone know how to get it all done in one step though instead of two?

 

proc copy in=kcurr out=knew;
    select &k4.;
run;
proc datasets library=knew;
    change &k4.=k4;
run;
quit;

Super User
Posts: 19,805

Re: Renaming a dataset during a proc copy

Ome suggestion would be that you can use proc datasets to copy as well as rename. 

 

Another, which I would test for speed, is to use PROC Append, it uses a block copy method as well and doesn't require the base data to be pre-existing. Not sure if it's as fast as proc copy though. 

Super User
Posts: 10,028

Re: Renaming a dataset during a proc copy

you could try. But I don't know if it could work:

 


proc datasets library=kcurr ;

   change &k4.=k4;

run;

   copy out=knew;
run;
quit;

Super Contributor
Posts: 345

Betreff: Renaming a dataset during a proc copy

[ Edited ]

Use proc datasets and "change"-statement to rename the dataset after/before it is copied. Unfortunately proc copy has no rename option.

 

Well, i am to slow today :-|

☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 4 replies
  • 2349 views
  • 0 likes
  • 4 in conversation