missing numerical values = - infinity?

  • Follow


Going into rant mode... I discovered a feature of SAS that I wish I had
known earlier: SAS will assign a value of *negative infinity* to missing
numerical values in logical statements.

So in the following code:

if birth_weight<2500 then low_birth_weight=1;
else if birth_weight>=2500 then low_birth_weight=0;

SAS will assign all missing values (birth_weight=.) to the category
low_birth_weight=1, since negative infinity is less than 2500.

Why SAS programmers settled on this convention I don't know. Wouldn't it
make more sense if birth_weight=., then low_birth_weight=.?

At any rate, the good news is that it's easy to correct the above code:

if 0<birth_weight<2500 then low_birth_weight=1;
else if birth_weight>=2500 then low_birth_weight=0;

Robert Feyerharm
Oklahoma State Department of Health
0
Reply robertf (42) 12/23/2009 8:52:28 PM

RTFM on functions ifc and ifn

See example code on this page:

Conditionally Executing Global Statements

http://tinyurl.com/25ba6l for

http://www.sascommunity.org/wiki/Conditionally_Executing_Global_Statemen
ts

which shows that false==0 is the key to understanding Boolean evaluation

Ron Fehd the mostly Boolean maven

-----Original Message-----
From: Robert Feyerharm
Sent: Wednesday, December 23, 2009 12:52 PM
Subject: missing numerical values = - infinity?

Going into rant mode... I discovered a feature of SAS that I wish I had
known earlier: SAS will assign a value of *negative infinity* to missing
numerical values in logical statements.

So in the following code:

if birth_weight<2500 then low_birth_weight=1;
else if birth_weight>=2500 then low_birth_weight=0;

SAS will assign all missing values (birth_weight=.) to the category
low_birth_weight=1, since negative infinity is less than 2500.

Why SAS programmers settled on this convention I don't know. Wouldn't it
make more sense if birth_weight=., then low_birth_weight=.?

At any rate, the good news is that it's easy to correct the above code:

if 0<birth_weight<2500 then low_birth_weight=1;
else if birth_weight>=2500 then low_birth_weight=0;

Robert Feyerharm
Oklahoma State Department of Health
0
Reply rjf2 (3354) 12/23/2009 10:58:57 PM


1 Replies
206 Views

(page loaded in 0.045 seconds)

Similiar Articles:













7/24/2012 11:24:03 AM


Reply: