trying to understand my mate's code. I have never seen this before but what does in (.) mean?
if adj_fac not in (.)
is equal to
if adj_fac ne .
Maybe someone did not remember the mnemonic for "not equal" 😉
I see. why not just not missing? so much easier to read.
not missing(adj_fac)
works too. There are many ways to do this.
..or:
if adj_fac > .z then ...
🙂
Bart
if adj_fac ne .
is less typing than
if not missing(adj_fac)
Good programmers are lazy (Linus Torvalds) 🙂
But those two are not equivalent.
1 data test;
2 adj_fac = .B;
3 if adj_fac ne . then x1=1;
4 if not missing(adj_fac) then x2=1;
5 put _all_;
6 run;
adj_fac=B x1=1 x2=. _ERROR_=0 _N_=1
Bart
@Nietzsche wrote:
I see. why not just not missing? so much easier to read.
For any question relating to "WHY" you must ask the programmer.
I can see a scenario where a prior version of the programming used a list of values with or without the missing. Then needs changed and the list was reduced or replaced leaving the . as the only list.
I have code where I have some code like " IN ('one value') " instead of "variable = 'one value' " because history has shown me that I am very likely to have to add values.
They probably used to have other values in the list of excluded values.
if adj_fac not in (. 0 -1 999) then ...
And they removed the others and did not bother to change from the IN operator to equality operator once there was only one value left in the list.
it means adj_fac was not missing. I wouldn't have written it that way. I prefer the missing function like others have mentioned here.
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.
Ready to level-up your skills? Choose your own adventure.