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;
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
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.