BookmarkSubscribeRSS Feed
Ronein
Onyx | Level 15

Hello

This code rename data set A (in library Work) to data set B (in library work).

I want to rename data set A (in data set work) into data set B in library RRR.

What is the way to do it please?

proc datasets library=WORK;
   change A=B;
run;
6 REPLIES 6
Kurt_Bremser
Super User

Data step.

Renaming might only work if

  • it is done in the operating system (external command, XCMD required)
  • the permanent library is on the same physical volume as WORK; otherwise, the mv command (if on UNIX) will do a copy followed by delete

Make sure that options (COMPRESS!) are replicated.

ChrisNZ
Tourmaline | Level 20

You can't. Renaming a file works if the file doesn't move (I know @Kurt_Bremser, the mv command thinks otherwise :).

Here the data set is going to a different library, so you must move (or copy) it, not rename it.

Astounding
PROC Star
Rather than using a DATA step, a faster method would be to use PROC COPY.
Ronein
Onyx | Level 15

Can you show the full code please with PROC COPY  that rename data set work.A  into  data set RRR.A ?

PaigeMiller
Diamond | Level 26

It's not a rename, it's not a move, it's a copy. Once you do this, you now have two exact identical copies of the data set, one in library WORK and one in library RRR. The documentation is here.

 

proc copy in=work out=rrr;
    select a;
run;
quit;

 

--
Paige Miller

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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
  • 1551 views
  • 7 likes
  • 5 in conversation