BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
NewUsrStat
Lapis Lazuli | Level 10

Hi guys,

suppose to have:

 

       Id               Place 

       A                Hosp1

       A                Hosp2

       B                Hosp1

       B                Hosp1

       C                Hosp3

       C                Hosp4

 

I would like the following:

       Id                Place 

       C                Hosp3

       C                Hosp4

 

So I if Place =Hosp1 delete not only the single record but instead the entire Id. Basically I would like to remove Ids containing Hosp1. Can anyone help me please? Thank you very much

1 ACCEPTED SOLUTION

Accepted Solutions
PaigeMiller
Diamond | Level 26

From now on, please provide data as WORKING data step code, as shown below.

 

data have;
    input Id $ Place $;
    cards;
       A                Hosp1
       A                Hosp2
       B                Hosp1
       B                Hosp1
       C                Hosp3
       C                Hosp4
;

proc sql;
	create table want as select *
	    from have
	    group by id having max(place='Hosp1')=0;
quit;
--
Paige Miller

View solution in original post

1 REPLY 1
PaigeMiller
Diamond | Level 26

From now on, please provide data as WORKING data step code, as shown below.

 

data have;
    input Id $ Place $;
    cards;
       A                Hosp1
       A                Hosp2
       B                Hosp1
       B                Hosp1
       C                Hosp3
       C                Hosp4
;

proc sql;
	create table want as select *
	    from have
	    group by id having max(place='Hosp1')=0;
quit;
--
Paige Miller