Hi Everyone,
I am not sure what to do with the sort below.
I just sort by var (character) and the result is:
I try to compress ( var, ". -") to eliminate these character and the sort on the variable but still doesn't help.
Can anyone tell me how to move TestPros in from of the TREX?
Many thanks.
HHC
SES |
TREX- OII |
TREX- TI |
TestPros |
VA-SP |
Hi,
A primary linguistic collation rule is to treat alphabetic characters equally regardless of case.
proc sort data=need sortseq=linguistic(strength=primary);;
by val ;
run;
Try the CASEFIRST option?
By default capital letters sort before lower case.
If case doesn't matter for order, but does matter for appearance, then I would consider creating a duplicate variable that is all one case and sorting by that.
You should also look into the Linguistic/Collating options to change the order.
But, if none of those work and you need a custom order, a format is the best approach, but it's essentially manual at that point.
Hi,
A primary linguistic collation rule is to treat alphabetic characters equally regardless of case.
proc sort data=need sortseq=linguistic(strength=primary);;
by val ;
run;
If I understand you correctly you simply want TestCase to appear after SES and before TREX- Oil
Assuming I'm correct this should give you what you need
data have;
length test $8;
infile datalines;
input test;
datalines;
SES
TREX- OII
TREX- TI
TestPros
VA-SP
run;
proc sql;
create table want
as select test
from have
order by lowcase(test);
quit;
Thank you,
With all kind of option, SAS should make it simpler 🙂
HHC
Maybe the following code could get you what you want.
data have;
length test $8;
infile datalines;
input test;
datalines;
SES
TREX- OII
TREX- TI
TestPros
VA-SP
run;
proc sql;
create table want
as select test
from have
order by compress(test, ,'ka');
quit;
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 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.