What Is Proc Sort in Sas

PROC SORT first arranges the data set by the values in ascending order, by default, of the first BY variable. PROC SORT then arranges any observations that have the same value of the first BY variable by the values of the second BY variable in ascending order. This sorting continues for every specified BY variable. Tip.

How do you use proc sort?

PROC SORT DATA=auto OUT=auto3 ; BY DESCENDING foreign ; RUN ; PROC PRINT DATA=auto3 ; RUN ; You can see in the proc print below that the data are now ordered by foreign, but highest to lowest. It is also possible to sort on more than one variable at a time.

How do I sort in SAS?

  1. If you list just one variable, then SAS will sort the observations in the dataset based on ascending values of that variable. …
  2. You can sort in descending order by placing the keyword DESCENDING before the variable name that you want the dataset to be sorted on. …
  3. You can sort by as many variables as are in the dataset.
James H. Sterling

James H. Sterling

Environmental Science & Climate Journalist

James Sterling reports on renewable energy developments, climate policy, ecological conservation, and green tech innovations around the globe.

Share this article
Twitter Facebook Pinterest