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 - SAS Tutorial
From the course: SAS® 9.4 Cert Prep: Part 09 Summarizing Data
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…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
(Locked)
Answering questions about groups43s
-
(Locked)
Processing sorted data in groups1m 11s
-
(Locked)
Demo: Identifying the first and last row in each group4m 8s
-
(Locked)
Subsetting rows in the Execution phase2m 29s
-
(Locked)
Demo: Creating an accumulating column within groups2m 59s
-
(Locked)
Using multiple BY columns1m 14s
-
(Locked)