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

Goal

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 the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.