Given A, B, C
In order for A to stay, it needs to be greater than either B or C.
If A is less than BOTH B and C, it gets tossed.
In SAS-speak, the following doesn't appear to be correct. Can someone please offer guidance?
if A < (B and C) then A = . ;
Using 'or' doesn't seem to work either.
Oh, and, these are numeric variables, numbers....
Hey, it's been a long day.
I haven't tried this code, but it something like that...
If A < B or A < C then A = .;
If A gt B or A gt C then A = .;
Those variables are numerical? What kind of values do you have on each column? May you will have some problem when calculating the values.
In order for A to stay, it needs to be greater than either B or C.
Must be translated to the logic expression A > B or A > C.
If A is less than BOTH B and C
Means: A < B and A < C
Next step: what should happen if A = B and A = C?
And: why should A be set to missing if it should "stay"?
Terrific, @Kurt_Bremser . How easy that was. Thanks!
Shows the great usefulness of max(), min(). And also, not().
@NKormanik wrote:
Given A, B, C
In order for A to stay, it needs to be greater than either B or C.
If A is less than BOTH B and C, it gets tossed.
In SAS-speak, the following doesn't appear to be correct. Can someone please offer guidance?
if A < (B and C) then A = . ;
Using 'or' doesn't seem to work either.
Oh, and, these are numeric variables, numbers....
Hey, it's been a long day.
It is "correct" in the way that SAS works. When you place a comparison in () such as (B and C) it evaluates that expression. Then returns the result of that expression as 1 (for true) or 0 for false. The comparison (B and C), since you use a Logic expression is testing "is B true and is C true". Which returns 1 when both are "true" or 0 if any are not "true". Values of 0 or missing are not "true".
Example:
data example; input b c; result = (b and c); datalines; 1 1 0 1 . 1 . . 2 3 -4 5 6 7 1000000 .000004 ;
So your code was asking, essentially, is "A <0" or is "A<1" depending on the values of B and C.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.