Stupid that it's not really possible to do it in an easy fashion, but I created a macro program to fix that. Minus one last trailing space on the last row. Hm... Anyway: *Create the macro program;
%macro exportWithoutExtraLine(lib_name,ds_name,export_file);
*Get the variables in the order of the data set.;
proc sql noprint ;
select name into : all_vars separated by ","
from dictionary.columns
where upcase(libname) = upcase("&lib_name") and upcase(memname) = upcase("&ds_name")
order by varnum;
quit;
*Export the file to CSV.;
data _null_;
file "&export_file" recfm=n;
length row $1000;
set &lib_name..&ds_name;
row = catx( ",", &all_vars);
if _n_ > 1 then put "0D0A"x +(-1); *Deal with trailing spaces... ;
put row +(-1); *Deal with trailing spaces... ;
run;
%mend exportWithoutExtraLine;
*Call the macro program with your parameters, there is a comma between the libname and the data set name! ;
%exportWithoutExtraLine(sashelp,baseball,G:\temp\file.csv);
... View more