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;
The 2025 SAS Hackathon has begun!
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.