Preprocessing Data

Determine Whether the Data Requires Preprocessing

Before you perform BY-group processing on one or more data sets using the SET, MERGE, and UPDATE statements, you must check the data to determine whether it requires preprocessing. The data requires no preprocessing if the observations in all of the data sets occur in one of the following patterns:
  • ascending or descending numeric order
  • ascending or descending character order
  • not alphabetical or numerical order, but grouped in some way, such as by calendar month
If the observations are not in the order that you want, sort the data set before using BY-group processing.

Example: Sorting Observations for BY-Group Processing

You can use the SORT procedure to change the physical order of the observations in the data set. You can either replace the original data set, or create a new, sorted data set by using the OUT= option of the SORT procedure. In this example, PROC SORT rearranges the observations in the data set Cert.Usa in ascending order based on the values of the variable Manager. Then, the sorted data is created as a new, sorted data set Work.Usa.
Note: The default sort order for the SORT procedure is ascending.
proc sort data=cert.usa out=work.usa;
  by manager;
run;
proc print data=work.usa;
run;
Specify the variables in the PROC SORT BY statement in the same order that you intend to specify them in subsequent DATA or PROC steps.
The following output shows the Work.Usa data set sorted by the variable Manager in ascending order.
Output 8.1 Sorted Work.Usa Data Set
Sorted Work.Usa Data Set
Last updated: August 23, 2018
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.137.188.201