BookmarkSubscribeRSS Feed
viollete
Calcite | Level 5

Hi ,

 

I have this information (this is just an example):

 

Year Month Hospital Nr_beds

2016 12 RA 210

2017 1 RA 215

2017 2 RA .

2016 12 RB .

2017 1 RB 650

2017 2 RB 651

2016 12 RC 120

2017 1 RC 150

2017 2 RC 170

 

 

I want to extract only hospital who has no missing values in the variable Nr_beds. In new table I want to have just hospital RC, but not RA (cause it does not have information for time 2017/2) and hospital RB (cause it does not have information for time 2016/12)

3 REPLIES 3
RW9
Diamond | Level 26 RW9
Diamond | Level 26

Post test data in the form of a datastep.

A simple where seems to cover your request:

data want;
  set have;
  where hospital="RC" and nr_beds ne .;
run;
Ksharp
Super User

data have;
input Year Month Hospital $ Nr_beds;
cards;
2016 12 RA 210
2017 1 RA 215
2017 2 RA .
2016 12 RB .
2017 1 RB 650
2017 2 RB 651
2016 12 RC 120
2017 1 RC 150
2017 2 RC 170
;

proc sql;
create table want as
 select * from have
  group by Hospital
   having nmiss(Nr_beds)=0;
quit;


Ksharp
Super User

data have;
input Year Month Hospital $ Nr_beds;
cards;
2016 12 RA 210
2017 1 RA 215
2017 2 RA .
2016 12 RB .
2017 1 RB 650
2017 2 RB 651
2016 12 RC 120
2017 1 RC 150
2017 2 RC 170
;

proc sql;
create table want as
 select * from have
  group by Hospital
   having nmiss(Nr_beds)=0;
quit;


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
  • 3 replies
  • 469 views
  • 0 likes
  • 3 in conversation