Monday 26 December 2016

SAS Treating a Missing Value

Each programming language has an IF-THEN articulation that branches as indicated by whether a Boolean expression is valid or false. In SAS, the IF-THEN (or IF-THEN/ELSE) articulation assesses an expression and braches as per whether the expression is nonzero (genuine) or zero (false). The fundamental linguistic structure is

in the event that numeric-expression then

do-calculation;

else

do-elective calculation;





One of the intriguing components of the SAS language is that it is intended to handle missing qualities. This raises the question: What happens if SAS experiences a missing worth in an IF-THEN expression? Does the IF-THEN expression regard the missing quality as "genuine" and execute the THEN articulation, or does it regard the missing worth as "false" and execute the option ELSE proclamation (in the event that it exists)?

information A;

input x @@;

on the off chance that x then Expr="True ";

else Expr="False";

datalines;

1 0 .

;

proc print noobs;

run;

temp2

Ok ha! SAS translates a missing worth as "false."

furthermore check the outcome for the beneath program:

information A;

input x @@;

if not x then Expr="True ";

else Expr="False";

datalines;

1 0 .

;

proc print noobs;

run;

temp

Ok ha! SAS deciphers a missing quality as "genuine."

All the more effectively, here is a selection from the SAS documentation:

SAS assesses the expression in an IF-THEN explanation to create an outcome that is either non-zero, zero, or missing.

A non-zero and nonmissing result causes the expression to be valid; a consequence of zero or missing causes the expression to be false.

On the off chance that you don't need missing qualities to be dealt with as "false," then don't reference a variable specifically, yet rather utilize a Boolean expression in the IF-THEN articulation.

For instance, in the accompanying explanation a missing worth outcomes in the THEN articulation being executed, while all other numerical qualities keep on behaving not surprisingly.

No comments:

Post a Comment