Reputation: 4554
In trying to make my code more readable, I face the following situation.
Consider a data step in which you want to select only observations which have a value for variable
. It seems there are two ways to do this using a WHERE statement: express the variable alone or use the MISSING function.
For example,
Case 1. Where VARIABLE
data where_var;
set sashelp.electric;
where AllPower;
run;
Case 2. Where not missing(VARIABLE)
data where_not_missing;
set sashelp.electric;
where not missing(AllPower);
run;
These produce the same result. However, I'm unsure whether this is necessarily the case.
Upvotes: 2
Views: 2762
Reputation: 475
If you are trying to determine if AllPower
has a value then only Case 2 will work.
Case 1 is selecting records where AllPower
is non-zero. Zero is a value and is not the same as missing.
Upvotes: 0
Reputation: 376
In SAS, any numeric value other than 0 or missing is true. See https://support.sas.com/documentation/cdl/en/lrcon/62955/HTML/default/viewer.htm#a000780367.htm for more info.
That means that your Case 1 and Case 2 are not 100% equivalent. If AllPower = 0, the result will be different.
Upvotes: 5