*Copyright @ www.mycsg.in;


Sequential row numbering and group size counting within BY groups

What this lesson covers

Create sample data

Sequential row numbering within each group

Using RETAIN and FIRST to number rows

Alternative: using a sum statement directly

Group size counting - how many rows are in each group

Two-pass approach using PROC FREQ or PROC SQL

One-pass approach using RETAIN and LAST

Combined row number and group size in one dataset

Key points to remember