id month sale flag
101 m1 230 0
101 m2 240 1
101 m3 230 0
102 m1 450 0
102 m2 430 1
102 m3 480 1
102 m4 450 0
As with your earlier question, you need to provide a lot more details.
As stated, this is not a SAS question at all. In fact, it's not a question at all.
data have;
input id month $ sale flag ;
cards;
101 m1 230 0
101 m2 240 1
101 m3 230 0
102 m1 450 0
102 m2 430 1
102 m3 480 1
102 m4 450 0
;
run;
What is your logic? data have; input id month $ sale ; cards; 101 m1 230 0 101 m2 240 1 101 m3 230 0 102 m1 450 0 102 m2 430 1 102 m3 480 1 102 m4 450 0 ; run; data want; set have; by id; if first.id or last.id then flag=0; else flag=1; run;
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
Still thinking about your presentation idea? The submission deadline has been extended to Friday, Nov. 14, at 11:59 p.m. ET.
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.