LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous messageNext messagePrevious in topicNext in topicPrevious by same authorNext by same authorPrevious page (March 2009, week 3)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Thu, 19 Mar 2009 20:24:17 -0500
Reply-To:     Lou <lpogoda@HOTMAIL.COM>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         Lou <lpogoda@HOTMAIL.COM>
Organization: A noiseless patient Spider
Subject:      Re: Sort and Merge
Comments: To: sas-l@uga.edu

"FPAStatman" <brentvtimothy@gmail.com> wrote in message news:724dce79-0717-476a-9429-26fa6fb6a3e5@e18g2000yqo.googlegroups.com... > I have run into an interesting error, which I cannot figure out how to > solve. I will provide an example of what I am doing below: > > DATA a; > INPUT name $ id; > CARDS; > northwest 1 > northeast 2 > southwest 1 > southeast 2 > ; > DATA b; > INPUT name $ input; > CARDS; > northwest 5 > southwest 6 > ; > PROC SORT data=a; > BY name; > PROC SORT data=b; > BY name; > > DATA b; > MERGE b a; > BY name; > > This is a simplification of the process, but basically the same. I > then get an error saying: > ERROR: BY variables are not properly sorted on the dataset user.a. > > Why are they not properly sorted after a sort statement? There is no > error in the sort statment, and it says that SAS sort was used. > > Thanks

Apparently you've oversimplified - the code you posted runs without generating an ERROR message on SAS 9.1 under Windows. (It's not correct, mind you, unless you're aiming at a rather odd result - it just doesn't generate an error message.)

The usual reason for an error in situations like this is that the BY variable has different lengths on the two datasets being merged and you list the dataset with the shorter length first. That sets the length of that variable to the shorter length, and values get truncated on the second dataset. Admittedly, that's not the case here.


Back to: Top of message | Previous page | Main SAS-L page