merge old(in=a) trap(in=b); by this that; if a and not b then check='Only l'; if b and not a then check='Only n'; if a and b then check='Match'; if a or b then output; run;
Hello team,
Will "if a or b then output" be back in the result only? Please advise.
Respectfully,
blueinthesky
@GN0001 wrote:
merge old(in=a) trap(in=b); by this that; if a and not b then check='Only l'; if b and not a then check='Only n'; if a and b then check='Match'; if a or b then output; run;Hello team,
Will "if a or b then output" be back in the result only? Please advise.
Respectfully,
blueinthesky
This is the exact type of problem you should try yourself, and see what happens. If you take SASHELP.CLASS and remove a few rows and create data set A, then take SASHELP.CLASS and remove other rows and create data set B, then merge by NAME, you will see what happens.
Ask yourself:"what does the OUTPUT statement do?"
You'll have your answer.
And then ask yourself if the statement is necessary at all. Can there ever be a case where neither a nor b is true?
Hello Kurt,
That is what I try to say. The last statement is not needed at all. I did what paigemiller suggested, All the cases of two tables are discussed earlier, so, that last statement is not needed, and it is not correct at all. I kind of knew that before I posted my question, I wanted to make sure.
Thanks,
Blue
@GN0001 wrote:
Hello Kurt,
That is what I try to say. The last statement is not needed at all. I did what paigemiller suggested, All the cases of two tables are discussed earlier, so, that last statement is not needed, and it is not correct at all. I kind of knew that before I posted my question, I wanted to make sure.
Thanks,
Blue
This is where I wanted to lead you. If your question had been "I do not think that the last IF statement is needed. Is this correct?" my answer would simply have been "Yes, you are right".
@GN0001 wrote:
merge old(in=a) trap(in=b); by this that; if a and not b then check='Only l'; if b and not a then check='Only n'; if a and b then check='Match'; if a or b then output; run;Hello team,
Will "if a or b then output" be back in the result only? Please advise.
Respectfully,
blueinthesky
This is the exact type of problem you should try yourself, and see what happens. If you take SASHELP.CLASS and remove a few rows and create data set A, then take SASHELP.CLASS and remove other rows and create data set B, then merge by NAME, you will see what happens.
@GN0001 wrote:
Thanks for response. Why do you mean remove? Do you mean to create a subset?
Thanks one more time.
Blue blue
SASHELP.CLASS has 19 rows. If you remove some rows, the new data set has fewer than 19.
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.