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.
Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!
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.