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.
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
Still thinking about your presentation idea? The submission deadline has been extended to Friday, Nov. 14, at 11:59 p.m. ET.
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.