data want;
set have;
by id;
if last.id then flg='Y'; else flg='.';
run;
If I may be so bold, setting FLG to 'Y' or '.' is not such a good idea; setting FLG to numeric 0 or 1 is not only easier to type, but has other benefits as well (such as computing proportions that are flagged can be done by computing a mean).
--
Paige Miller