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

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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