Date: Mon, 1 Oct 2001 10:24:13 -0600
Reply-To: Jack Hamilton <JackHamilton@FIRSTHEALTH.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Jack Hamilton <JackHamilton@FIRSTHEALTH.COM>
Subject: Re: PROC SORT
Content-Type: text/plain; charset=iso-8859-1
This is an interesting and apparently little-used feature of PROC SORT. I wonder if it is better known outside the USA, where the idea of using a different character set is not so unheard-of.
Coincidentally, I turned in a SUGI paper proposal on PROC SORT which discusses the SORTSEQ option; I don't know whether it will be accepted. It's straightforward to use, but deciding which of the hundreds of translation tables to use in any given situation might be problematic. Unicode will eventually solve these problems, I suppose.
--
JackHamilton@FirstHealth.com
Development Manager, Technical Group
METRICS Department, First Health
West Sacramento, California USA
>>> "Peter Crawford" <peter.crawford@DB.COM> 10/01/2001 4:53 AM >>>
A national language support feature provides a useful clue for a
simple solution here. From the on-line doc for proc trantab, it is
clear that one of the default translation tables is for lower to upper
case translation. You only have to define this translate table on the
SORTSEQ= option of the proc sort statement.
The actual value is obviously platform dependant. I found the
default val;ue (SASUCS) shown on on-line doc not valid for
my UK SAS v8.1 on winNT. Instead WLT1_UCS works just fine !
data names;
length name $32;
input name & ;
datalines;
Hold
Keep
private Lives
counterparty ID
;
proc sort OUT=NORMAL;
by name;
run;
dm 'fsv';
proc sort sortseq=WLT1_UCS out=w_ucs;
by name;
run;
dm 'fsv';
produces these windows
+FSVIEW: WORK.NORMAL (B)---------------------+
| Obs name |
| |
| 1 Hold |
| 2 Keep |
| 3 counterparty ID |
| 4 private Lives |
| |
+---------------------------------------------+
+FSVIEW: WORK.W_UCS (B)----------------------+
| Obs name |
| |
| 1 counterparty ID |
| 2 Hold |
| 3 Keep |
| 4 private Lives |
| |
+---------------------------------------------+
Looks like the simplest way to provide "case-insensitive" sorting !
regards
Peter Crawford
Datum: 01/10/2001 09:40
An: SAS-L@LISTSERV.UGA.EDU
Antwort an: "Karsten M. Self" <kmself@IX.NETCOM.COM>
Betreff: Sort w/ folded case (was Re: PROC SORT)
Nachrichtentext:
on Mon, Oct 01, 2001 at 01:01:59AM -0700, ninon (ndavi@AUFEMININ.COM) wrote:
> Hi,
>
> I want to sort a data set with small letter and capital letter
> like :
>
> Before the sort the data set is :
>
> Paris
> London
> Bruxelle
> france
> belgique
>
> After the sort the data set is :
>
> belgique
> Bruxelle
> france
> London
> Paris
>
> with a PROC SORT how I do it ?
> THANKS
> NINON
I'd pick SQL instead:
proc sql;
create table mydata as
select *
from mydata
order by (upcase( city ))
;
quit;
SQL allows you to sort by a condition or result which isn't itself a
field/column in the input table/dataset. Very handy, that.
You could substitute 'lowcase' for 'upcase' in the above, so long as the
conversion is consistent.
Note that for the purposes of merging or joining the data, the dataset
isn't strictly sorted.
Peace.
--
Karsten M. Self <kmself@ix.netcom.com>
--
Diese E-Mail enthält vertrauliche und/oder rechtlich geschützte Informationen. Wenn Sie nicht der richtige Adressat sind oder diese E-Mail irrtümlich erhalten haben, informieren Sie bitte sofort den Absender und vernichten Sie diese Mail. Das unerlaubte Kopieren sowie die unbefugte Weitergabe dieser Mail ist nicht gestattet.
This e-mail may contain confidential and/or privileged information. If you are not the intended recipient (or have received this e-mail in error) please notify the sender immediately and destroy this e-mail. Any unauthorized copying, disclosure or distribution of the material in this e-mail is strictly forbidden.