BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
GN0001
Barite | Level 11
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

 

Blue Blue
1 ACCEPTED SOLUTION

Accepted Solutions
PaigeMiller
Diamond | Level 26

@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.

--
Paige Miller

View solution in original post

8 REPLIES 8
Kurt_Bremser
Super User

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?

GN0001
Barite | Level 11
Can you please explain a little bit more?
Thanks
Blue
Blue Blue
GN0001
Barite | Level 11

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

Blue Blue
Kurt_Bremser
Super User

@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".

PaigeMiller
Diamond | Level 26

@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.

--
Paige Miller
GN0001
Barite | Level 11
Thanks for response. Why do you mean remove? Do you mean to create a subset?
Thanks one more time.
Blue blue
Blue Blue
PaigeMiller
Diamond | Level 26

@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.

--
Paige Miller

SAS Innovate 2025: Register Now

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!

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 8 replies
  • 1008 views
  • 2 likes
  • 3 in conversation