BookmarkSubscribeRSS Feed
danwarags
Obsidian | Level 7

I have a data set which has many missing values. I am trying to eliminate the missing values by using if then else statement. But I could not do that. The dataset which I have is in labelled and formatted form. 

 

data sample;

input age $gender $race;

datalines;

4 M 

1 F hispanic

3 F black

 . M 

7    Hispanic

5 M white

;

 

output 

 

 

I want to include only the observations with full data eliminating the missing values. For example, from the above data I need to include only 2nd and 6th rows in the data set eliminating all the rows with missing observations. How can I do that. 

 

 

 

 

3 REPLIES 3
PGStats
Opal | Level 21

Try

 

if cmiss(of _numeric_, of _character_) = 0;

 

PG
Haikuo
Onyx | Level 15

@PGStats wrote:

Try

 

if cmiss(of _numeric_, of _character_) = 0;

 


Can we just :

 

if cmiss(of _all_) = 0;

 

Astounding
PROC Star

Is your data already in a SAS data set, or are you needing to read it in?  This variation would overcome problems with INPUT when there are fewer than 3 items on a line:

 

data want;

input @;

if scan(_infile_, 3, ' ')=' ' then delete;

else input age gender $ race $;

datalines;

4 M 

1 F hispanic

3 F black

 . M 

7    Hispanic

5 M white

;

 

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 3 replies
  • 2048 views
  • 3 likes
  • 4 in conversation