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.

Using multiple BY columns

Using multiple BY columns

- [Instructor] You know that if you sort data by more than one column, SAS sorts the data based on the first BY column, and then sorts the second BY column within each unique value of the first BY column. In this table, the rows are first sorted by year. Then within year, they are sorted by quarter. Can you also process this data by groups? If multiple columns are listed on the BY statement in the data step, then each column has its own First./Last. variables in the PDV. The First./Last. variables for Qtr represent when a value for Qtr begins and ends within a particular year. The First./Last. variables are dropped from the output data, but to create this example table, we've used assignment statements to create permanent variables so you can see the values. Notice for this highlighted row, First.Qtr is equal to one. It isn't the first time Qtr is equal to one in the table, but it is the first occurrence of quarter one…

Contents