The ODS OUTPUT statement creates SAS data sets from the output objects that PROC TABULATE produces. The name of each output object is Report. The MATCH_ALL option produces a SAS data set for each instance of Report. The name of the first data set is energyoutput, and the name of the second data set is energyoutput1. ODS stores a list of these names in the macro variable datasetnames. This variable is used later in the example to combine the data sets.

The KEEP= data set option limits the variables in the output data set to Region, Division, Type, and Expenditures_sum. The variable name Expenditures_sum is generated by PROC TABULATE to indicate that the variable Expenditures was used to calculate the sum statistic. The RENAME= data set option changes the name of the variable to Expenditures. (To learn the names of the variables in an output data set that ODS creates, use PROC CONTENTS or the Explorer window.)


ods output Report(match_all=datasetnames)
           =energyoutput(keep=region division type expenditures_sum
                         rename=(expenditures_sum=Expenditures));