Hi,
Just wanted to confirm: if a and ^b in "IF a AND ^b THEN OUTPUT ..." can be read as "if in a and not in b", is that correct?
I have googled this particular syntax and it doesn't appear in the results.
Thanks.
@jffeudo86 wrote:
Hi,
Just wanted to confirm: if a and ^b in "IF a AND ^b THEN OUTPUT ..." can be read as "if in a and not in b", is that correct?
I have googled this particular syntax and it doesn't appear in the results.
Thanks.
Depends. How did the variables A and B get assigned. By "in" do you mean coming from a data set? Then this would be true only if the dataset option in= was used:
data junk; merge one (in=a) two (in=b) ; if a and not b then output; end;
But "in a" above would mean "in data set one". There is no automatic membership logical variable set based on the source data set.
If the question is about the logical structure then there are different ways of doing the "not":
data example; input a b; z= a and ^b; y= a and not b; x= a and ~ b; datalines; 1 1 1 0 0 0 0 1 ; run;
The logical value is the same but not all keyboards use the ~ or ^.
And note that if you only have one data set on the DATA statement so that all of the output is going to that set conditionally then you don't even need the OUTPUT as
if a and not b;
is a subsetting if and the records that match the logic are the only ones kept.
@jffeudo86 wrote:
Hi,
Just wanted to confirm: if a and ^b in "IF a AND ^b THEN OUTPUT ..." can be read as "if in a and not in b", is that correct?
I have googled this particular syntax and it doesn't appear in the results.
Thanks.
Depends. How did the variables A and B get assigned. By "in" do you mean coming from a data set? Then this would be true only if the dataset option in= was used:
data junk; merge one (in=a) two (in=b) ; if a and not b then output; end;
But "in a" above would mean "in data set one". There is no automatic membership logical variable set based on the source data set.
If the question is about the logical structure then there are different ways of doing the "not":
data example; input a b; z= a and ^b; y= a and not b; x= a and ~ b; datalines; 1 1 1 0 0 0 0 1 ; run;
The logical value is the same but not all keyboards use the ~ or ^.
And note that if you only have one data set on the DATA statement so that all of the output is going to that set conditionally then you don't even need the OUTPUT as
if a and not b;
is a subsetting if and the records that match the logic are the only ones kept.
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.