BookmarkSubscribeRSS Feed
Chiranjeevi
Calcite | Level 5

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

 

4 REPLIES 4
PaigeMiller
Diamond | Level 26

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.

--
Paige Miller
thomp7050
Pyrite | Level 9
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;
Ksharp
Super User

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;

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 4 replies
  • 739 views
  • 1 like
  • 5 in conversation