BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
1 ACCEPTED SOLUTION

Accepted Solutions
andreas_lds
Jade | Level 19

And another way:

data want;
   set have;
   
   if _n_ = 1 then do;
      declare hash h(dataset: 'work.have(keep= id status where=(not missing(Status)))');
      h.defineKey('id');
      h.defineData('status');
      h.defineDone();
   end;
   
   rc = h.find();
   
   drop rc;
run;

View solution in original post

2 REPLIES 2
sbxkoenk
SAS Super FREQ

Hello,

 

data have;
input id city $ year status @@;
datalines;
1 A 1990 .
1 B 1995 .
1 C 2000 1
1 D 2001 .
2 C 1985 .
2 F 2011 .
3 A 1999 .
3 B 2000 1
3 E 2011 1
3 F 2012 .
;
run;

PROC FREQ data=have;
 tables id * status / list missing out=work.count(where=(status NE .));
run;

data want;
 merge have count(keep=id /* status */ in=incount);
 by id;
 if incount then status=1;
run;
/* end of program */

 

Koen

andreas_lds
Jade | Level 19

And another way:

data want;
   set have;
   
   if _n_ = 1 then do;
      declare hash h(dataset: 'work.have(keep= id status where=(not missing(Status)))');
      h.defineKey('id');
      h.defineData('status');
      h.defineDone();
   end;
   
   rc = h.find();
   
   drop rc;
run;