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-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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.

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