Let's say you have some data, you want to work with that data and you know that the data is currently ordered by REGION, but you need the data ordered by YEAR. So, ou would use PROC SORT to do the reordering:
proc sort data=perm.salesdata;
by year region;
would sort the data "in place" -- that means that by the time the sort was done, perm.salesdata would have been reorganized and would now be in order by year and then region within year.
But, if you had this:
proc sort data=perm.salesdata out=work.sales_year;
by year region;
then...the "original" file perm.salesdata would still be in the "original" order but the new (and temporary) file work.sales_year would be the same data, only ordered by year and then region within year.
In the above 2 instances, the BY statement is telling PROC SORT how to order the variables...so right now, I have BY YEAR REGION; which would order by YEAR first, then by REGION within YEAR.
If I had BY REGION YEAR; then I would get ordering by REGION first and then by YEAR within each region.
For more information PROC SORT, such as eliminating duplicates or sorting in descending order, I recommend the SORT documentation or you might consider contacting Tech Support for more help.
It seems that I did not undertand your question. In your original post, you asked "how to code a proc sort". So, I answered with several examples of PROC SORT syntax using a hypothetical data example.
PROC SORT has very simple syntax and you may list as many or as few variables on the BY statement as you want or need to -- based on the particular report or process that you are going to produce. For example, if you have data and you were going to use PROC SQL with the data, then I would not bother to use PROC SORT first, because PROC SQL can do an "ORDER BY". On the other hand, if you were going to use PROC PRINT with a PAGEBY and/or BY statement, you would need to use PROC SORT first to get the data in the right order for PROC PRINT.
For help with this question, your best bet is to contact Tech Support.