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;
Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!
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.
Ready to level-up your skills? Choose your own adventure.