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.

hackathon24-white-horiz.png

The 2025 SAS Hackathon Kicks Off on June 11!

Watch the live Hackathon Kickoff to get all the essential information about the SAS Hackathon—including how to join, how to participate, and expert tips for success.

YouTube LinkedIn

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 944 views
  • 2 likes
  • 3 in conversation