Could you please explain below code ;
data xyz;
input x $;
cards;
AA
AA
AA
BB
BB
;
run;
data A;
set xyz;
by x;
if first.x then
N+1;
run;
output :-
Obs x N
1 AA 1
2 AA 1
3 AA 1
4 BB 2
5 BB 2
data B;
set xyz;
by x;
if first.x then N=1;
else N+1;
run;
output for B is
Obs x N
1 AA 1
2 AA 2
3 AA 3
4 BB 1
5 BB 2
I know how dateset B is created its the incrementing the value based of the occurrence of by group x but not sure how dataset A is being created .
Please explain.