From the course: SAS® 9.4 Cert Prep: Part 09 Summarizing Data

Unlock this course with a free trial

Join today to access over 22,600 courses taught by industry experts.

Demo: Creating an accumulating column within groups

Demo: Creating an accumulating column within groups - SAS Tutorial

From the course: SAS® 9.4 Cert Prep: Part 09 Summarizing Data

Demo: Creating an accumulating column within groups

- [Instructor] So you've seen how you can use First dot or Last dot variables to keep only the first or last row within groups. This is only one of many practical benefits of this syntax. You can also use First dot, Last dot variables to prompt for some action to occur at the beginning or end of each group. Let's take a look at the weather data for Houston again. We created an accumulating total for the daily rain column during the entire year, using a SUM statement. But what if we want to create a month-to-date total column? In other words, we want to create an accumulating column named MTD or month-to-date rain, but reset it each time a new month begins. Let's see how to do this in a demo. Here we'll use the First dot variable to reset an accumulating column for rain totals at the beginning of each month. Let's take a look at this data stat. We're reading the weather, Houston table, and we're creating a data set…

Contents