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

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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