You should verify the output of your code using independent method. For example, run your sequential double sort/rank on your test data using excel and then verify that you get the same results with your SAS code. This way you will know for certain that your code is operating as expected.
... View more