DATA Step, Macro, Functions and more

Copy sas dataset from work library to permanent library

Accepted Solution Solved
Reply
Contributor
Posts: 30
Accepted Solution

Copy sas dataset from work library to permanent library

[ Edited ]

Is there any easy way to copy all dataset from work library to permanent library? Ex:- Suppose I have 10 dataset to be in work library (test1, test2 .. test10) and I want to copy all of them in permanent library ( libname data "/.") with same name.

 

Is there any proc that could do that or only way is to get work location and loop all dataset from work location and store it to permanent dataset ?

 

Thanks,


Accepted Solutions
Solution
‎03-29-2016 01:47 PM
Respected Advisor
Posts: 3,777

Re: Copt sas dataset from work library to permanent library

You might consider the SAS system option USER.  This will allow all one level names to be written to the library specified in the option.

 

https://support.sas.com/documentation/cdl/en/lesysoptsref/68023/HTML/default/viewer.htm#p1tl8adik7yp...

View solution in original post


All Replies
Super User
Posts: 17,784

Re: Copy sas dataset from work library to permanent library

Proc copy or proc datasets. 

 

Solution
‎03-29-2016 01:47 PM
Respected Advisor
Posts: 3,777

Re: Copt sas dataset from work library to permanent library

You might consider the SAS system option USER.  This will allow all one level names to be written to the library specified in the option.

 

https://support.sas.com/documentation/cdl/en/lesysoptsref/68023/HTML/default/viewer.htm#p1tl8adik7yp...

Trusted Advisor
Posts: 1,115

Re: Copt sas dataset from work library to permanent library

It's not quite clear from your post whether this is a one-time task or if you plan to do this regularly, occasionally or as part of a larger SAS program.

 

If you just want to prevent automatic deletion of the work datasets at the end of a SAS session, you can use the NOWORKTERM system option:

options noworkterm;

An easy way to copy SAS datasets and catalogs (perhaps you need work.formats, too?) manually from one library to another is to use the SAS Explorer.

 

As another alternative to SAS procedures, especially if you are familiar with the corresponding command of your operating system (copy, cp, ...), you can also let SAS submit this via an X command. As shown below (example for Windows), you don't need to know physical paths of libraries for this:

x "copy %sysfunc(pathname(work))\test*.sas7bdat C:\Temp";
Contributor
Posts: 30

Re: Copy sas dataset from work library to permanent library

Thanks Reeza,  data _null_ and  . Appreciate all your help. Good learning in terms of user option. all solutions were very handy and what I was looking for. even used all of them in different project and for different need. Thanks again for your help.

Contributor
Posts: 30

Re: Copy sas dataset from work library to permanent library

Thanks Reeza,  data _null_ and FreelanceReinhard . Appreciate all your help. Good learning in terms of user option. all solutions were very handy and what I was looking for. even used all of them in different project and for different need. Thanks again for your help.

 

 

☑ This topic is SOLVED.

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

Discussion stats
  • 5 replies
  • 341 views
  • 0 likes
  • 4 in conversation