From the course: SAS® 9.4 Cert Prep: Part 05 Analyzing and Reporting on Data

Demo: Enhancing reports

- [Instructor] In this demo, we'll use titles, footnotes, labels and grouping to enhance a report. So let's think about the storm_final table. This is our clean SaaS dataset. I'll run the proc print step just to see what we have to start with. So we have one row per storm. The MaxWin, MinPressure, StartDate and the calculated StormLength. Those are the columns that had been included in the report because of the var statement and proc print. So let's say I'd like to enhance that report a bit. Specifically I'd like to look at category five storms and I'd like to group the report by the basin name. I would also like to provide some titles and descriptive labels for the column headers to enhance the display. So in order to create a grouped report, the first thing I need to do is sort the input data. So before proc print, I'm going to add a proc sort. The input data will be the storm_final table. And I'll create an output table named storm_sort. I'd like to group the data by BasinName. And then within BasinName, I'd like to order the storms based on descending MaxWindMPH. That way the stronger storm will be at the time of each basin group. Now, I said we also wanted to look specifically at category five storms. So I'll sum set the data where MaxWindMPH is greater than 156. So the proc sort step will create our temporary storm_sort table that is ordered in the groups that I want to display in the report. So my proc print needs to instead use the storm_sort table as its input. In order to group the data within my report, I need to add a by statement in proc print. So I want to group by BasinName. I'll add a title to the report so before proc print, I'll use the title statement to add category five storms. And I'll also add a label statement within proc print. I'll start with the keyword label and then the variable name on the left, MaxWindMPH equal and then in quotes the label. I'll complete the label statement for other columns as well. Now notice I can use a single label statement to create assignments for each of these four columns. Remember, it's a good practice if you create a title to also clear that title at the end of the program. So I'll add a title null statement at the end. Let's run it at this point and see how the results look. I'll check the log first, and we notice there are only Notes in the results. But if I look at the results, we can see the title looks good, the report grouping looks great. We have a separate table for each BasinName and you'll notice that MaxWindMPH is ordered in descending sequence. However, where are my labels? You'll notice I'm still looking at column names. And just as another side note, I still have this observation column that's included by default. So what did I forget? Well, I'll go back to the code and remember that in proc print, we actually have to request that labels be displayed in the output with the label option. It's the one procedure that requires we request the labels be displayed. All other procedures will display labels by default. And to get rid of that obs column, I can use the noobs options. So I'll resubmit the proc print step and it looks great. My labels are displayed in the report.

Contents