BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Jack1
Obsidian | Level 7

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.

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User

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

5 REPLIES 5
ballardw
Super User

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.

Jack1
Obsidian | Level 7

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

Jack1
Obsidian | Level 7

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;

Reeza
Super User

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. 

Jack1
Obsidian | Level 7

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

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

Register Now

Creating Custom Steps in SAS Studio

Check out this tutorial series to learn how to build your own steps in SAS Studio.

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
  • 5 replies
  • 21181 views
  • 0 likes
  • 3 in conversation