Hello, first time user for a couple of weeks now and have an issue with the SORT function.
When I sort by var (which is numeric, 1 until 13) I get:
1
10
11
12
13
2
3
4
5
6
etc.
In my other similar database I didn't have this issue, strange. Anyone knows how to fix this? Here's the basic code:
Proc sort data = data out = sorteddata;
by variable;
RUN;
Thanks.
It doesn't look like a numeric I am afraid. It looks like that variable is a character, hence it Is sorting textually.
It doesn't look like a numeric I am afraid. It looks like that variable is a character, hence it Is sorting textually.
I just ran a PROC CONTENTS and you're right. I find it strange it switched to Char, since it was Num in my main database, but thanks!
There is an option in proc sort can do that ,you need to check documentation . another way is sql.
Here is :
NUMERIC_COLLATION=on
Message was edited by: xia keshan
Where do I put this in my code? Just out of curiosity. I just changed my variable to numeric by multiplying it by 1 now. Thanks.
data test; length v $ 3; input v; cards; 1 10 11 12 13 2 3 4 5 6 ; run; proc sort data=test sortseq=linguistic(numeric_collation=on); by v; run; proc print data=test; run;
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 25. Read more here about why you should contribute and what is in it for you!
Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.