BookmarkSubscribeRSS Feed
deleted_user
Not applicable
I have 2 tables
Thanks!
3 REPLIES 3
Doc_Duke
Rhodochrosite | Level 12
To use a MERGE with a BY statement, the observations are joined on matching values of CD. Since you have none, the example data would have 8 observations. Your "if in1 and in2;" statement is what causes the output dataset to have 0 observations.

To include all rows of T1, change the IF statement to
IF in1;
In this example, your output dataset, e1, would be the same as t1.

To understand this behavior, get rid of the DROP and subsetting IF, and add a KEEP statement for in1 and in2 and then look at the output.

This paper will help
http://support.sas.com/techsup/technote/ts705.pdf
(I just searched support.sas.com for "merge examples".)

Doc Muhlbaier
Duke
deleted_user
Not applicable
Sorry I am kind of new to SAS, but isn't this 'If in1 and in2' statement applicable for assigning the job id to batch id? Why should it affect the MErge?
Doc_Duke
Rhodochrosite | Level 12
&job_id is a macro variable that you haven't defined. To more fully answer your questions, you need to provide a complete example of what you are trying to do and the answers you are looking for. I did answer your question of how to include all rows of T1, but your response indicates that is not the problem you were trying to solve.

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

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
  • 3 replies
  • 2504 views
  • 0 likes
  • 2 in conversation