Hi,
So I'm very unfamiliar with SAS but have been working with the University Edition. I have a CD file of .sas7bdat files that I need to convert into CSV files. My issue is that when the CSV file is generated, I'm getting an error in the SAS log and my CSV file (which opens in excel) does not have anything in it. Data is the name of the library I created to hold my data (but I'm not even sure if I did that correctly) and this is the code I'm running (donor is the name of my data file I'm trying to convert):
proc export data=data.donor
outfile=_dataout
dbms=csv replace;
run;
%let _DATAOUT_MIME_TYPE=text/csv;
%let _DATAOUT_NAME=donor.csv;
This is the error I'm getting:
Hi,
That is my full code. I went to the "snippets" section and chose "generate CSV file" which gives me this:
proc export data=sashelp.cars
outfile=_dataout
dbms=csv replace;
run;
%let _DATAOUT_MIME_TYPE=text/csv;
%let _DATAOUT_NAME=cars.csv;
what I posted in my original question is what i changed it to so I could try and convert my file. Again, I seriously don't know anything about SAS and I'm trying to do this for a professor who also does not know SAS so thank you for your help!!!
So yes, my data is in the "myfolders" folder I created at set up. Should I be able to expand the library when I'm in the library tab to see my data? Even when i try to recreate the library I'm not able to open the files or expand under the library I created. I'm able to open the files in SAS so i can see that they're valid and contain data, so I know thats ok. I just think I'm setting up my library wrong or something.
libname mydata '/folders/myfolders/';
proc export data=myData.data1 outfile = "/folders/myfolders/data1.csv" dbms=csv replace;
run;
That's usually all you need then run the PROC EXPORT for each file.
Change the DATA = to be your data set name and the name in the outfile portion as well.
@bhanl004 wrote:
So yes, my data is in the "myfolders" folder I created at set up. Should I be able to expand the library when I'm in the library tab to see my data? Even when i try to recreate the library I'm not able to open the files or expand under the library I created. I'm able to open the files in SAS so i can see that they're valid and contain data, so I know thats ok. I just think I'm setting up my library wrong or something.
libname data "/folders/myfolders";
run;
proc export data=donor.sas7bdat
outfile='_donor.csv'
dbms=csv replace;
run;
%let _DATAOUT_MIME_TYPE=text/csv;
%let _DATAOUT_NAME=donor.csv;
The lib statement runs successfully, but I still cannot expand it out when I'm under libraries so I cant select the export option.
@bhanl004 wrote:
libname data "/folders/myfolders";
run;
proc export data=donor.sas7bdat
outfile='_donor.csv'
dbms=csv replace;
run;
%let _DATAOUT_MIME_TYPE=text/csv;
%let _DATAOUT_NAME=donor.csv;The lib statement runs successfully, but I still cannot expand it out when I'm under libraries so I cant select the export option.
You created a libref of DATA, but you don't use it.
Instead you told PROC EXPORT to read the dataset named SAS7BAT from the libref named DONOR.
If you have a file named donor.sas7bdat in the folder you pointer DATA at then you can use either
data=data.donor
in your PROC EXPORT statement.
Or just skip the libname statement and use:
data='/folders/myfolders/donor'
or
data='/folders/myfolders/donor.sas7bdat'
Note that if the file is actually named DONOR.sas7bdat or Donor.sas7bdat then SAS will not be able to see it. The name of the file must be in all lowercase because SAS University Edition is running on a Unix machine (virtual) and Unix treats the case of the letters in filenames as significant.
So when I run that, I'm still getting the same error.
Code:
libname data "/folders/myfolders";
run;
proc export data=DATA.donor
outfile='_donor.csv'
dbms=csv replace;
run;
%let _DATAOUT_MIME_TYPE=text/csv;
%let _DATAOUT_NAME=donor.csv;
Log:
You do not have a file in that folder named donor.sas7bdat.
If you think you have such a file double check the location (is it really in the directory you used?) and the file name (perhaps it is donors.sas7bdat? Perhaps the filename a blank in the beginning or end that you are no seeing).
The filename (donor.sas7bdat) must be in all lowercase letters or SAS will not see it.
Okay, so you helped me figure out the issue with my name/library. and now my code is running without issue, but my CSV file is still showing up blank with no values when I open it. I know there is data in the files I'm converting, so I'm not sure why this is happening.
p.s. - thank you for the help!!!
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 16. Read more here about why you should contribute and what is in it for you!
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.