Example 8.4 Separating the First Observation in a BY Group from the Other Observations in the BY Group


Write the first observation in a BY group to one data set. Write the other observations in the BY group to a second data set.

Example Features

Featured StepDATA step
Featured Step Options and StatementsFIRST.variable and LAST.variable temporary variables
Related TechniquePROC SORT, DUPOUT=, NODUPKEY, and OUT= options

Input Data Set

Data set TRADE_ASSN contains membership records for four members of a trade association. Each observation stores the membership information for one company for one year. Note that three of the four companies have more than one observation and that one company, Surname Associates, has only one observation.

Get Combining and Modifying SAS® Data Sets: Examples Second Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.