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;
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
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.
Ready to level-up your skills? Choose your own adventure.