BookmarkSubscribeRSS Feed
deleted_user
Not applicable
Two tables:

A with variables ID, X, Y.
B with variables ID, Z

Merging:

data C;
merge A B;
by ID;
run;

If anyone of A and B is not sorted by ID, shouldn't there be a message in the log about it?
4 REPLIES 4
Flip
Fluorite | Level 6
Only if they are not in the correct order. The message is generated when data lines are encountered in the wrong order, not due to a sort indicator.
deleted_user
Not applicable
Thanks for your answer.

In my example above table A was sorted by ID with PROC SORT, but table B was not.

So, since there was no message concerning table B, I can draw the conclusion, for sure, that the records in B was in correct order?

You NEVER have to worry when there is a BY in the merging, that you get something that you don't want?
sbb
Lapis Lazuli | Level 10 sbb
Lapis Lazuli | Level 10
As long as you do not code the BY statement parameter NOSORTED. Useful reading below, for your consideration.

Scott Barry
SBBWorks, Inc.

SAS Language Reference: Concepts, Processing BY-Groups in the DATA Step
http://support.sas.com/documentation/cdl/en/lrcon/61722/HTML/default/a000761932.htm
data_null__
Jade | Level 19
MERGE does not support BY statement with NOTSORTED option.

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 16. 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
  • 4 replies
  • 969 views
  • 0 likes
  • 4 in conversation