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: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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