Hi,
I have attempted to export a SAS dataset to .csv using the following piece of code but to no avail:
PROC EXPORT DATA=XXX;
OUTFILE="File Pathname"
DBMS=CSV REPLACE;
PUTNAMES=YES;
RUN;
In fact, I received an error message that states the following:
ERROR: FILE= or TABLE= is required and must be specified.
Therefore, I would greatly appreciate it if someone could offer a solution to this issue. Thanks in advance!
Remove the highlighted Semi-colon and try
PROC EXPORT DATA=XXX ;
OUTFILE="File Pathname"
DBMS=CSV REPLACE;
PUTNAMES=YES;
RUN;
Should be :
PROC EXPORT DATA=XXX
OUTFILE="File Pathname"
DBMS=CSV REPLACE;
PUTNAMES=YES;
RUN;
Thank you so much for detecting that error! It works now!
You have to remove the semi-colon after DATA=XXX;
Thank you so much for detecting that error! It works now!
Here is a coding style tip to help avoid that type of error.
When you have a statement that spans multiple lines put the semi-colon that ends the statement on its own line:
PROC EXPORT DATA=XXX
OUTFILE="File Pathname"
DBMS=CSV REPLACE
;
PUTNAMES=YES;
RUN;
The same way that you would place the END for a DO/END block:
if a=b then do;
statement1;
statement2;
end;
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!
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.