How to Copy and Move Datasets from Work to Other Library in SAS

In this tutorial we will learn how to copy and move Datasets from Work to Other Library in SAS. Hope you all know all the dataset which is created without library reference are by default stored in Work library and flushed when the session ends.

Suppose at the end of your program execution you suddenly realized that the dataset you have created may be needed in future for further processing and if you re-execute it will take lots of time. So instead of re-executing your code you can simply copy or move all your datasets from work library to some permanent library.

Let’s see an example to understand more clearly.

 

Copy Datasets from Work to Other Library in SAS

To copy your datasets from work to other permanent library in SAS you have to follow these steps:

  • Create a permanent library using libname statement.
  • Copy your all datasets from work library using proc dataset procedure.

 

LIBNAME PERMANENT '/home/trenovision/Permanent';

 

PROC DATASETS LIBRARY=WORK MEMTYPE=DATA;
COPY OUT=PERMANENT;
RUN;

Move Datasets from Work to Other Library in SAS

To copy your datasets from work to other permanent library in SAS you have to follow these steps:

  • Create a permanent library using libname statement.
  • Move your all datasets from work library using proc dataset procedure.
LIBNAME PERMANENT '/home/trenovision/Permanent';

 

PROC DATASETS LIBRARY=WORK MEMTYPE=DATA;
COPY OUT=PERMANENT MOVE;
RUN;

Hope you are now more clear how you can Copy And Move Datasets Between Libraries in SAS feel free to comment if you have any query or error you’re while executing this code.

Happy Learning !!