|
Sure, but you don't need the line that starts with if _n_ eq 1. It doesn't
hurt, but you'll get the same result with or without it.
Art
------
On Fri, 19 Aug 2011 22:09:46 -0400, Randy <randistan69@HOTMAIL.COM> wrote:
>my data set is as follows:
>
>ID
>A
>A
>A
>B
>B
>B
>B
>B
>C
>C
>
>What I need is
>
>ID ID_Group
>A 1
>A 1
>A 1
>B 2
>B 2
>B 2
>B 2
>B 2
>C 3
>C 3
>
>The code I wrote is as follows:
>
>Data Need ; set Have;
>by ID;
>If _N_ = 1 then ID_Group = 0 ;
>If first.ID then ID_Group +1 ;
>run;
|