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

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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
  • 1 reply
  • 513 views
  • 1 like
  • 2 in conversation