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?
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;
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;
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 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.
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?
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.
@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.
Define "others". Other SAS users? If yes, sharing a SAS server with you? If no, in what format should they receive the data?
If you use SAS On Demand, you do not have access from your SAS session to your local computer. You have to use the download feature of SAS Studio to transfer data.
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 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?
@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.
Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!
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.