1
votes

I am trying to export my processed SAS datasets into text files (.txt) with an UTF8 encoding. It seems proc export doesn't have an encoding option and putting the encoding option in the libname statement doesn't work. I also tried using the data step below but the text files are all empty (0 rows) and I really don't like this approach as it creates the SAS datasets all over again.

 %do i=1 %to &num_file;
 data out.&&filename&i. (encoding=UTF8);
 set in.&&filename&i.;
 file "&dir.\&&filename&i...txt";
 run;
 %end;
1

1 Answers

3
votes

You are trying to specify the encoding on an output data set, not the file.

data _null_;
set sashelp.cars;
file "c:\temp\cars.txt" encoding="utf-8";
put _all_;
run; 

http://support.sas.com/documentation/cdl/en/lestmtsref/67175/HTML/default/viewer.htm#n15o12lpyoe4gfn1y1vcp6xs6966.htm