Building models with SAS Enterprise Miner, SAS Factory Miner, SAS Visual Data Mining and Machine Learning or just with programming

Why the is missing operator is not working with if then statement?

Reply
Contributor
Posts: 49

Why the is missing operator is not working with if then statement?

data one;

infile datalines missover;

input age;

if age is missing then age=9999;

else age=age;

cards;

8

01

20

0

1

2

;

proc print;

run;

PROC Star
Posts: 1,230

Re: Why the is missing operator is not working with if then statement?

Hi,

You probably want the missing FUNCTION.  Try:

if missing(age) then age=9999;

Also I would suggest you use SAS special missing values instead of numeric codes.  So:

if missing(age) then age=.S;

--Q.


Contributor
Posts: 43

Re: Why the is missing operator is not working with if then statement?

Also, the "is missing" syntax is used with the "where" clause, as in Proc SQL or as a filter on Proc freq, for example.

Proc freq data = . . . ;

where age is missing ;

tables . .  . ;

In a DATA step, use:

if age = . then age = 9999 ;

(and you really don't need the else clause)

Super User
Posts: 10,483

Re: Why the is missing operator is not working with if then statement?

Or

if missing(age) then age=9999;

Ask a Question
Discussion stats
  • 3 replies
  • 318 views
  • 0 likes
  • 4 in conversation