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;

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 2 replies
  • 346 views
  • 1 like
  • 3 in conversation