In this code:
proc sort data=MLB out=salaries_sorted;
format Salary dollar12.3;
by descending Salary descending Year;
You are taking the input dataset MLB
, and creating a new sorted table salaries_sorted
. You're adding a format there (I'm not sure that works, but even if it does, it's a very unusual place to put it), and then you're telling it how to sort (by salary and year, both descending order).
Then, in this code:
proc print data=MLB (obs=10);
run;
You're printing the top 10 observations of the MLB
dataset - but not the sorted dataset.
In order to print the sorted dataset's top 10 rows, you'd need to do this:
proc print data=salaries_sorted(obs=10);
run;
If you don't want the name to change, you can skip the out=salaries_sorted
part (and then the MLB dataset will itself be sorted), but it's normally good practice to sort into a new dataset.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…