DATA Step, Macro, Functions and more

Merge by column has NULL values

Reply
N/A
Posts: 0

Merge by column has NULL values

I have 2 tables
Thanks!
Trusted Advisor
Posts: 2,116

Re: Merge by column has NULL values

Posted in reply to deleted_user
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
N/A
Posts: 0

Re: Merge by column has NULL values

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?
Trusted Advisor
Posts: 2,116

Re: Merge by column has NULL values

Posted in reply to deleted_user
&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.
Ask a Question
Discussion stats
  • 3 replies
  • 317 views
  • 0 likes
  • 2 in conversation