BookmarkSubscribeRSS Feed
Babloo
Rhodochrosite | Level 12
How to convert the following merge step into joins. I just given the structure of the merge and in similar fashion I need to achieve the same in Joins.

Data merge;
If a(in=x) b(in=y);
By id;
If x and y;
Then;
Do;
F=7;
End;
If x;
Then;
Do;
F=3;
End;
If y;
Then;
Do;
F=9;
End;
Run;

1 REPLY 1
ballardw
Super User

@Babloo wrote:
How to convert the following merge step into joins. I just given the structure of the merge and in similar fashion I need to achieve the same in Joins.

Data merge;
If a(in=x) b(in=y);
By id;
If x and y;
Then;
Do;
F=7;
End;
If x;
Then;
Do;
F=3;
End;
If y;
Then;
Do;
F=9;
End;
Run;


Because of the way that SAS treats same-named variables in different data sets without a complete example for data in all data sets involved it is not possible to determine even if a similar join is possible. Since you do not actually show a MERGE statement (or SET or other statement that actually indicates source data sets) in your example it is even harder. You example code will throw multiple errors as is.

 

Plus, post code in code box opened with the forum's {I} menu icon so formatting such as indents are preserved.

SAS Innovate 2025: Call for Content

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!

Submit your idea!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 1 reply
  • 582 views
  • 0 likes
  • 2 in conversation