BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
PunkinSAS08
Fluorite | Level 6

I am a new user on SAS 9.4 and cannot figure out how to save a dataset created in SAS session/code to my computer.  I have tried using the file command to  set the pathway to save the file and it does not work : 

data EE.EE2016_2021;
set EE2016_2021;
file "G:\Research Labs\Evans\NTDB TQIP PUF\IDH-Work";
run;

 

any suggestions?

1 ACCEPTED SOLUTION

Accepted Solutions
Tom
Super User Tom
Super User

I don't know what you mean by "save a dataset created in SAS session/code to my computer".

You can save a dataset on the computer where SAS is running.  Whether or not that is YOUR computer I don't know,. 

 

To permanently save a dataset make a libref pointing to a directory ("folder") on the computer where SAS is running and use the libref when naming the dataset.

libname EE 'some directory name on SAS computer';
data EE.EE2016_2021;
  set EE2016_2021;
run;

If you are running SAS on your computer, that is you have SAS 9.4 installed locally, then the path could be something like "G:\Research Labs\Evans\NTDB TQIP PUF\IDH-Work" assuming that the G: drive exists (or has something mapped to it) and the directory named \Research Labs\Evans\NTDB TQIP PUF\IDH-Work exists there and you have permission to write there.

 

If you are running SAS on some other computer, perhaps by using and interface like SAS/Studio or perhaps Enterprise Guide, then you would need to point and click your way around that interface to see how to download a file from the machine where SAS is running to machine where you are running the interface.

 

People normally just mount the same disks on both computers. Say your SAS code is running on UNIX you would just have the systems team mount the G:\Research Labs\ share to some location in the Unix filesystem.  Then your code would look more like:

libname EE '/whereever they mounted it/Evans/NTDB TQIP PUF/IDH-Work' ;
data EE.EE2016_2021;
  set EE2016_2021;
run;

View solution in original post

12 REPLIES 12
Tom
Super User Tom
Super User

I don't know what you mean by "save a dataset created in SAS session/code to my computer".

You can save a dataset on the computer where SAS is running.  Whether or not that is YOUR computer I don't know,. 

 

To permanently save a dataset make a libref pointing to a directory ("folder") on the computer where SAS is running and use the libref when naming the dataset.

libname EE 'some directory name on SAS computer';
data EE.EE2016_2021;
  set EE2016_2021;
run;

If you are running SAS on your computer, that is you have SAS 9.4 installed locally, then the path could be something like "G:\Research Labs\Evans\NTDB TQIP PUF\IDH-Work" assuming that the G: drive exists (or has something mapped to it) and the directory named \Research Labs\Evans\NTDB TQIP PUF\IDH-Work exists there and you have permission to write there.

 

If you are running SAS on some other computer, perhaps by using and interface like SAS/Studio or perhaps Enterprise Guide, then you would need to point and click your way around that interface to see how to download a file from the machine where SAS is running to machine where you are running the interface.

 

People normally just mount the same disks on both computers. Say your SAS code is running on UNIX you would just have the systems team mount the G:\Research Labs\ share to some location in the Unix filesystem.  Then your code would look more like:

libname EE '/whereever they mounted it/Evans/NTDB TQIP PUF/IDH-Work' ;
data EE.EE2016_2021;
  set EE2016_2021;
run;
PunkinSAS08
Fluorite | Level 6

I think my question may have not been clear. I cleaned a dataset and want to save it as it's own  separate sas7bdat file using SAS 9.4. How do I export this? I have tried using the file>export data drop down menu but it does not work correctly as I am working with a large dataset.

PunkinSAS08
Fluorite | Level 6
save it as it's own so that others can access the file once saved in my G drive.
PaigeMiller
Diamond | Level 26

@PunkinSAS08 wrote:
save it as it's own so that others can access the file once saved in my G drive.

What is stopping you? @Tom has provided code that will do that.

--
Paige Miller
PunkinSAS08
Fluorite | Level 6

because once I use this method, which saves to my G drive, once I try to open the sas7bdat file I receive the error:

ERROR: Tables with 0 columns are not supported by this object. TMP4.ee2016_2021 cannot be opened. Do you want to select a different table to open?

PaigeMiller
Diamond | Level 26

Please show us the code you used to create this saved file, and the log for this code. Please show us the code you used to open this saved file and the log for this code.

--
Paige Miller
Tom
Super User Tom
Super User

@PunkinSAS08 wrote:

because once I use this method, which saves to my G drive, once I try to open the sas7bdat file I receive the error:

ERROR: Tables with 0 columns are not supported by this object. TMP4.ee2016_2021 cannot be opened. Do you want to select a different table to open?


I suspect the terminology you are using is not only confusing those that are trying to help you but also confusing you.

 

You do not "save" a dataset.  You create a dataset.  You can use a data step to make a dataset.  Or you can use a PROC that can output a dataset.  Like PROC SORT or PROC COPY or even PROC MEANS.

 

If you ran a data step to create a dataset on the G drive but did not provide the data step any source data then you will make a dataset with zero observations and zero variables.  So you probably ran something like:

data ee.mydataset;
run;

Make sure to read the SAS log from the step(s) you are using to create the dataset you want to share.  Make sure that the notes in the log reflect what you expected to happen.  For example here is a simple data step that just copies a dataset without making any other changes.

1    data want;
2      set sashelp.class;
3    run;

NOTE: There were 19 observations read from the data set SASHELP.CLASS.
NOTE: The data set WORK.WANT has 19 observations and 5 variables.
NOTE: DATA statement used (Total process time):
      real time           0.01 seconds
      cpu time            0.00 seconds

Notice how it tells me how many observations were read and how many were written.  Also home many variables the new dataset has.

PunkinSAS08
Fluorite | Level 6

I think my question may have not been clear. I cleaned a dataset and want to save it as it's own  separate sas7bdat file using SAS 9.4. How do I export this? I have tried using the file>export data drop down menu but it does not work correctly as I am working with a large dataset.

PaigeMiller
Diamond | Level 26

@PunkinSAS08 wrote:

I think my question may have not been clear. I cleaned a dataset and want to save it as it's own  separate sas7bdat file using SAS 9.4. How do I export this? I have tried using the file>export data drop down menu but it does not work correctly as I am working with a large dataset.


Not really more or less clear than before.

 

Have you tried the suggestions from @Tom ? Is the idea from @Kurt_Bremser helpful if you are using SAS on Demand for Academics or SAS Studio? Exactly what is preventing you from saving such a file?

--
Paige Miller
Kurt_Bremser
Super User

@PunkinSAS08 wrote:

I think my question may have not been clear. I cleaned a dataset and want to save it as it's own  separate sas7bdat file using SAS 9.4. How do I export this? I have tried using the file>export data drop down menu but it does not work correctly as I am working with a large dataset.


There is no export needed. A SAS dataset is already stored in a .sas7bdat file. All you need to do is download the file from the server, if you work in a client/server SAS environment.

Please tell us how you use SAS.

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 12 replies
  • 893 views
  • 0 likes
  • 4 in conversation