- data aaa;
- input id x $;
- cards;
- 1 a
- 1 a
- 2 b
- 3 .
- 4 a
- 4 b
- 5 a
- 5 b
- 5 c
- 5 a
- 5 b
- 5 a
- ;
- run;
- proc sort data = aaa;
- by id;
- run;
- data bbb;
- set aaa;
- by id;
- if first.id then y = 0;
- if x = 'a' then y + 1;
- if last.id then output;
- drop x;
- run;