You get the same results without RETAIN, which is not needed for the sum statements.
Example:
PROC SORT DATA= sashelp.class out=have;
BY sex;
DATA WANT;
SET HAVE;
BY sex;
IF FIRST.sex
THEN SUM_NO=0;
ELSE SUM_NO+1;
RUN;
I think the original post from @karthik18 is missing a semi-colon, and that may be why it doesn't work. So, @karthik18 please examine your code carefully for a place where you need a semi-colon.
Of course, this still doesn't produce a sum or a count, it produces a "count" where the first record in each group is always 0.
... View more