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

Hi everyone,

 

I am new to SAS.

I mainly use SAS EG for my work because I am a novice to SAS. I am wondering where SAS stores the output after you ran code?

 

Apart from that, normally when running SAS, I want to export the output and afterwards, I will import such output to other SAS code to make sure that my code is not too long.

Traditionally, I use the export button and it leads me to save the file under sas7bdat or csv, or mdb, or txt format. 

 

So, I am not sure how to write the code to export this file under sas7bdat format and the code to import again rather than just export and import manually by using buttons

 

Or, I really appreciate if you can share any other solution from your experience by importing and exporting SAS output.

Cheers.

1 ACCEPTED SOLUTION

Accepted Solutions
Phil_NZ
Barite | Level 11

Export

libname myfolder 'path to folder';
proc copy in=work out=myfolder;
select export_dataset;
run;
quit;

Check export dataset

proc print data=myfolder.export_dataset;
run;

 

Import the export_dataset

 

Libname input 'path to folder';

data want;

set input.export_dataset;

run;

 

Thank you for your help, have a fabulous and productive day! I am a novice today, but someday when I accumulate enough knowledge, I can help others in my capacity.

View solution in original post

2 REPLIES 2
Phil_NZ
Barite | Level 11

Export

libname myfolder 'path to folder';
proc copy in=work out=myfolder;
select export_dataset;
run;
quit;

Check export dataset

proc print data=myfolder.export_dataset;
run;

 

Import the export_dataset

 

Libname input 'path to folder';

data want;

set input.export_dataset;

run;

 

Thank you for your help, have a fabulous and productive day! I am a novice today, but someday when I accumulate enough knowledge, I can help others in my capacity.
Kurt_Bremser
Super User

SAS datasets are already stored in files with a .sas7bdat extension, so there is no need to export. Just copy the files to the location where you want them.

Exporting is necessary when you want to create "external files", like csv or spreadsheets.

Text files (like csv) are written with a data step, Excel files can be created with PROC EXPORT or LIBNAME XLSX.

Since your SAS session most probably runs on a remote server, you need to download the exported files, this is done with the Copy Files task in EG.

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

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
  • 2 replies
  • 662 views
  • 2 likes
  • 3 in conversation