0

I am able to export SAS datasets into text files with UTF-8 encoding. But I saw that the format has totally changed when I converted to text with UTF-8 encoding. The program I used:

%do i=1 %to &num_file;
data _null_ (encoding="utf-8");
set sasdata.&&filename&i.;
file "&dir.\&&filename&i...txt" encoding="utf-8";
put _all_;
run;
%end;

The SAS dataset looks like:

Var_1  Var_2   Var_3 
100    ABC     40 

The text file looks like:

Var_1=100 Var_2=ABC Var_3=40 
Var_1=101 Var_2=DEF Var_3=20 

What do i need to get the same data layout but in a .txt file with UTF-8 encoding?


Thanks for directing me to that discussion, @Joe!! I was able to make this work with the following code:

%do i=1 %to &num_file; 
  FILENAME out&i. "&Report.\&&filename&i...txt" encoding="utf-8"; 
  proc export data=sasdata.&&filename&i. outfile=out&i. dbms=tab replace; 
  run; 
%end;
rom
  • 81
  • 4
  • 10

1 Answers1

2

That's what comes out when you use

put _all_;

It's unrelated to the UTF-8 file encoding. You need to use

put
@start variable length/format.
@start variable length/format.

etc., or any of the numerous other options for putting fixed-column data.

Joe
  • 62,789
  • 6
  • 49
  • 67