Sorry dude, you still did it wrong and it definitely works.
proc sort data=sashelp.stocks out=stocks;
by stock date;
run;
data want;
set stocks;
where stock = "IBM";
by date groupformat;
format date year4.;
if first.date then flag=1;
if last.date then flag=1;
run;
proc print data=want;run;
@Anddiy wrote: I've tried this, and did not work. CODE: DATA TEST_FORMAT; SET mytable; FORMAT DT_REFER YYMMN6.; BY GROUPFORMAT DT_REFER; RUN; In this case the group by didin't work, it is because if you just "format" a SAS DATE9. (Example: 19OCT2020) the sas will show you 202010, but for sas it's still 19OCT2020, because of that i have created a CHARACTER var for that and format that var to receive 202011....
... View more