When I try to read the csv file saved by SAS into python, I am getting unicode-decode error. The error was because of '0x80' character available in the file. it can be solved by explicitly defining the encoding when reading the file. But I need to solve it to in SAS while creating the .csv file.
Is there a way to define the encoding in the proc export code like (encoding='utf-8' etc
Code :
PROC EXPORT DATA= data1
OUTFILE= "F:\reports\&file_name..csv"
DBMS=CSV REPLACE;
RUN;
Did you try using a fileref?
filename csv "F:\reports\&file_name..csv" encoding='utf-8';
PROC EXPORT DATA= data1 REPLACE
OUTFILE= CSV DBMS=CSV
;
RUN;
Did you try using a fileref?
filename csv "F:\reports\&file_name..csv" encoding='utf-8';
PROC EXPORT DATA= data1 REPLACE
OUTFILE= CSV DBMS=CSV
;
RUN;
Thanks a lot. This worked!
Try assigning a FILEREF to the output data set and set the encoding there.
filename myfile 'paht to file' encoding=....;
proc export data=data outfile=myfile dbms=csv replace;
run;
@sreevatsan1991 wrote:
When I try to read the csv file saved by SAS into python, I am getting unicode-decode error. The error was because of '0x80' character available in the file. it can be solved by explicitly defining the encoding when reading the file. But I need to solve it to in SAS while creating the .csv file.
Is there a way to define the encoding in the proc export code like (encoding='utf-8' etc
Code :
PROC EXPORT DATA= data1
OUTFILE= "F:\reports\&file_name..csv"
DBMS=CSV REPLACE;
RUN;
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!
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.