DATA Step, Macro, Functions and more

Question regarding deleting missing values from two coloumns

Accepted Solution Solved
Reply
Occasional Contributor
Posts: 16
Accepted Solution

Question regarding deleting missing values from two coloumns

Hi,

I have a BP data where some of the id have missing data.  I want to delete only those rows where both the values(SBP and DBP) are missing.

 

My data look like this 

 

data have ;

id      date            SBP     DBP

1       1/1/2011     122       84

1       2/1/2011          .         .

1       3/1/2011     120       82

1       4/1/2011         .        86

2       1/1/2011     110       76

2       2/1/2011     146       88

2       3/1/2011     140         .

2       4/1/2011        .            .

3       1/1/2011     124       80

3       2/1/2011          .       88

3       3/1/2011     130       90

 

I want data like this

 

data want

id      date            SBP     DBP

1       1/1/2011     122       84

1       3/1/2011     120       82

1       4/1/2011         .        86

2       1/1/2011     110       76

2       2/1/2011     146       88

2       3/1/2011     140         .

3       1/1/2011     124       80

3       2/1/2011          .       88

3       3/1/2011     130       90

;

 

Kindly suggest 

 

Thanks in advance.


Accepted Solutions
Solution
‎04-05-2018 09:28 AM
PROC Star
Posts: 1,296

Re: Question regarding deleting missing values from two coloumns

Posted in reply to mehul4frnds
data want;
set have;
where coalesce(SBP,DBP)>.;
run;

View solution in original post


All Replies
Super User
Posts: 13,006

Re: Question regarding deleting missing values from two coloumns

Posted in reply to mehul4frnds

data want;

    set have;

    if not missing(SBP) and not missing(DBP);

run;

Occasional Contributor
Posts: 16

Re: Question regarding deleting missing values from two coloumns

Thanks or the reply.

This command deletes all the rows which have any of the missing values.

Solution
‎04-05-2018 09:28 AM
PROC Star
Posts: 1,296

Re: Question regarding deleting missing values from two coloumns

Posted in reply to mehul4frnds
data want;
set have;
where coalesce(SBP,DBP)>.;
run;
Occasional Contributor
Posts: 16

Re: Question regarding deleting missing values from two coloumns

Posted in reply to novinosrin

Thanks it worked 

☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 4 replies
  • 78 views
  • 0 likes
  • 3 in conversation