DATA Step, Macro, Functions and more

how to find this output

Reply
Occasional Contributor
Posts: 5

how to find this output

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

 

Trusted Advisor
Posts: 1,621

Re: how to find this output

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.

Frequent Contributor
Posts: 93

Re: how to find this output

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;
Super User
Posts: 9,682

Re: how to find this output


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;

Super User
Posts: 6,946

Re: how to find this output

Search, and you will find.

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
Ask a Question
Discussion stats
  • 4 replies
  • 147 views
  • 1 like
  • 5 in conversation