A very common coding technique SAS programmers use is identifying the largest value for a given column using DATA Step BY statement with the DESCENDING option. In this example I wanted to find the largest value of the number of runs (nRuns) by each team in the SASHELP.BASEBALL dataset. Using a SAS workspace server, one would write:
Figure 2 shows the results of the code we ran in Figure 1:
To run this DATA Step distributed we will leveraging the SAS® Cloud Analytic Services in SAS® Viya™. Notice in Figure 3, there is no need for the PROC SORT step which is required when running DATA Step single threaded in a SAS workspace server. This is because SAS® Cloud Analytic Services in SAS® Viya™ performs implicit ordering on BY variables. Notice on line 104 we do not supply the DESCENDING option because it is not supported in distributed DATA Step running in the SAS® Cloud Analytic Services in SAS® Viya™. Instead we will use LAST. processing, line 107, on the BY variable “team” to output the last record for each team. The last record of the BY variable “team” contains the largest value for the BY variable “nRuns”.
Figure 4 shows the results when running distributed DATA Step in SAS® Cloud Analytic Services in SAS® Viya™.
Until the BY statement running in the SAS® Cloud Analytic Services in SAS® Viya™ supports DESCENDING use this technique to ensure your DATA Step runs distributed.