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;
2025 SAS Hackathon: There is still time!
Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!