This is a proc sort.
I didn't know the names of the 13 variables in your BY statement, so you would have to replace the BY statement with the actual variables you are using.
Rather than typing the name of your incoming data set, I used a made-up name _16_variables. I expect you would use your actual data set name.
I used out= to avoid replacing the original data set. If you replace the original data set, the second PROC SORT would be skipped since SAS detects that the data set is already in sorted order.
So the idea is to run PROC SORT twice on the same data set, using out= to name the sorted data set. One PROC SORT uses TAGSORT and one doesn't.
If that's not clear, please ask again.
... View more