DATA Step, Macro, Functions and more

Data Step By Statement Sorting Failure

Reply
New Contributor
Posts: 3

Data Step By Statement Sorting Failure

Dear experts,

 

I'm trying to sort a column which has records like 'AA0276', 'A2B5Q', 'AB8ER', ...

 

After I sort the data, I'm running a data step and use the sorted column in a by statement.

 

The data step returns a ERROR which indicates that the by variable couldn't sorted for the values like 'AA0276' which have two consequent character values.

 

ERROR: Error: BY variables are not properly sorted.

 

How can I fix this problem?

 

 

PROC Star
Posts: 1,190

Re: Data Step By Statement Sorting Failure

If SAS says that your data is not sorted by that variable, it is not.

 

Post some sample data and your code.

New Contributor
Posts: 3

Re: Data Step By Statement Sorting Failure

[ Edited ]

Yes, that's obvious from the log but if you read my 2nd sentence you would see that I've sorted the data (using Proc Sort), it is sorted.

Super User
Posts: 6,543

Re: Data Step By Statement Sorting Failure

You'll have to post the log.  I can think of several possibilities, but I'm not about to explain them all in detail just in case one of them matches the situation you are encountering.

Super User
Posts: 22,874

Re: Data Step By Statement Sorting Failure


KaiBasch wrote:

Yes, that's obvious from the log but if you read my 2nd sentence you would see that I've sorted the data (using Proc Sort), it is sorted.


Post your full code and log. Obviously SAS doesn't think the data set is sorted for some reason.

Ask a Question
Discussion stats
  • 4 replies
  • 96 views
  • 0 likes
  • 4 in conversation