In this post, I will discuss How to sort data in SAS. Sorting plays a very important role in SAS. With and without sorting, data changes drastically in SAS. Consider the below data lines in SAS.
DATA EMP_DET; INPUT EMP_ID SALARY; DATALINES; 1 10000 2 10500 3 12000 1 13000 2 12300 3 15000 ; run;
When the above code executes, the output will be as below.
As it is clearly seen, data is neither sorted by salary nor by emp_id.
In order to sort the data, “proc sort” syntax is used. See the below SS and sharing the code as well.
INPUT EMP_ID SALARY;
proc sort data=EMP_DET;
When we execute the above mentioned code, the output will be sorted as per emp_id. See the below SS.