Running SAS on a mainframe environment like z/OS allows you to process massive enterprise datasets with high performance. Among the most commonly used SAS procedures are PROC SORT, which help you sort, filter, join and organize your data efficiently.

What is PROC SORT in SAS on Mainframe?

PROC SORT is one of the most frequently used procedures in SAS on z/OS. It allows to:

1. Sort large mainframe datasets
2. Apply filtering before sorting
3. Remove duplicates using NODUP or NODUPKEY
4. Prepare data for reporting or further analysis

Basic PROC SORT Example

The output will be sorted according to the weights. The Default is Ascending.

To use Descending, the syntax will be

Filtering Data Before Sorting

If the data needs to be filtered before sorting, then WHERE Option can be used in PROC SORT statement.
PROC SORT DATA=TEST (WHERE=(DELIVERY_NR='XXXXXXXXXX')) ;
BY WT;


Removing Duplicates

NODUPKEY option is used to remove duplicates based on the variable(s) specified in BY statement.
PROC SORT DATA=TEST NODUPKEY;
BY WT;


NODUP can be used when all the duplicates need to be removed based on values of all variables in the dataset.

Important PROC SORT Options

OptionPurpose
BYVariables to sort on
DESCENDINGSort in reverse order
WHERE=Filter before sort
NODUPKEYRemove duplicates based on BY variables
NODUPRemove duplicates based on entire row

Leave a comment

Discover more from DBzTech-Technology Dossier

Subscribe now to keep reading and get access to the full archive.

Continue reading