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;
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
Still thinking about your presentation idea? The submission deadline has been extended to Friday, Nov. 14, at 11:59 p.m. ET.
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.
Ready to level-up your skills? Choose your own adventure.