You could define a PROC SQL view including an ORDER BY clause and apply PROC EXPORT to this view. Then the sorting will occur during the PROC EXPORT step and without creating a sorted dataset.
Example:
data have;
set sashelp.class(keep=age weight);
run;
proc sql;
create view have_s as
select * from have
order by weight;
quit;
proc export data=have_s
outfile='C:\Temp\want.csv' dbms=csv replace;
run;
Register Today!
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.