SAS assigns transposed column names as the data is encountered. So you must sort your input data in the desired sequence ahead of the PROC TRANSPOSE execution -- however since you must use a BY statement with your PROC TRANSPOSE code, then you must also coded the NOSORTED option on the BY statement with PROC TRANSPOSE so that SAS will not complain that the data is not in sorted order (based on the BY variable list).
After running a test and reading the DOC, I now see that coding the NOTSORTED option with the sample data sorted by YEAR will result in multiple observations for the BY statement variable list since related observations are not contiguous.
As we have discussed previously, why do you need to have the variables (stored internally) in numeric sequence?
SAS creates the columns in the order they are encountered. Since you have no obs for 2005 for the first accno it will be created last. You could create an obs with variable = . for 2005 then sort prior to execution.
Easier is to simply specify the order to display the columns and not worry about the internal order.