Desktop productivity for business analysts and programmers

How to export a SAS Dataset from SAS EG work folder to a folder on my hard drive

Accepted Solution Solved
Reply
Contributor
Posts: 52
Accepted Solution

How to export a SAS Dataset from SAS EG work folder to a folder on my hard drive

I have a program file that exports individual Excel sheets as .csv files which represent a month of the year (12 total).  

 

In turn each of these .csv files are turned into a SAS dataset (again 12 total).  I then consolidate these monthly files into a single SAS dataset.  

 

Question: Is there a line (or lines) of code I can add to my program file to automatically export my consolidated SAS dataset into a folder on my computer?  I tried PROC EXPORT but it wouldn't work since the DBMS option apparently doesn't apply to SAS datasets?

 

I am new to SAS.  Any advice appreciated.

 

Thanks.


Accepted Solutions
Solution
‎06-06-2016 01:42 PM
Super User
Posts: 19,157

Re: How to export a SAS Dataset from SAS EG work folder to a folder on my hard drive

It isn't usually referred to export, but saving a dataset. You need to assign a library to save the data set.

You can use PROC COPY, or a DATA/PROC SQL step to move the data to the library. 

 

libname out 'c:\user\homareau\PredictiveModels\Attrition\';

proc datasets library=work nodetails nolist;
copy in=work out=out;
select naics_bankrupt_2013;
run;quit;

If you're running SAS on a server with EG on teh server this may not work, since EG will not be able to see your desktop.

In that case look for a TASK called Copy Files from Chris Hemindinger. 

View solution in original post


All Replies
Super User
Posts: 11,134

Re: How to export a SAS Dataset from SAS EG work folder to a folder on my hard drive

What format do you want the dataset exported to?

Some of the options for DBMS to specific databases such as Access, DB2, Teradata, Oracle and such require specific SAS/ACCESS modules loaded.

If you want a generic CSV or similar file it should work.

Please post the attempted Proc Export code for more targetted responses.

Contributor
Posts: 52

Re: How to export a SAS Dataset from SAS EG work folder to a folder on my hard drive

I want to export the SAS dataset as a SAS dataset...

Contributor
Posts: 52

Re: How to export a SAS Dataset from SAS EG work folder to a folder on my hard drive

This is what I tried:

 

proc export data=naics_bankrupt_2013 outfile='c:\user\homareau\PredictiveModels\Attrition\naics_bankrupt_2013.sas7bdat'
dbms=?? (no option for a SAS dataset here?)
label replace;
run;

Solution
‎06-06-2016 01:42 PM
Super User
Posts: 19,157

Re: How to export a SAS Dataset from SAS EG work folder to a folder on my hard drive

It isn't usually referred to export, but saving a dataset. You need to assign a library to save the data set.

You can use PROC COPY, or a DATA/PROC SQL step to move the data to the library. 

 

libname out 'c:\user\homareau\PredictiveModels\Attrition\';

proc datasets library=work nodetails nolist;
copy in=work out=out;
select naics_bankrupt_2013;
run;quit;

If you're running SAS on a server with EG on teh server this may not work, since EG will not be able to see your desktop.

In that case look for a TASK called Copy Files from Chris Hemindinger. 

Contributor
Posts: 52

Re: How to export a SAS Dataset from SAS EG work folder to a folder on my hard drive

Excellent Reeza!  Works like a charm.  Thanks again...Jack

☑ This topic is solved.

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

Discussion stats
  • 5 replies
  • 910 views
  • 0 likes
  • 3 in conversation