Date: Fri, 10 Nov 2000 18:17:00 -0500
Reply-To: HERMANS1 <HERMANS1@WESTAT.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: HERMANS1 <HERMANS1@WESTAT.COM>
Subject: Re: Problems with sorting range
Content-Type: text/plain; charset=US-ASCII
An interesting question, but the answer depends on the reason you need to sort
the field. Do you need to create a view of the data in Range sequence so you
can process rows in a proper sequence? If so, try something along the lines of
[untested]
proc sql;
create view RangeVW as
select put(input(scan(range,1,'-'),2.),z2.) /* lifted shamelessly from Mark
Terjeson''s answer.
*/
as range0,*
from <dataset>
order by range0
;
quit;
and use RangeVW as you would the original SAS dataset after sorting by Range.
This SQL solution works where you want the dataset sorted by the first element
in the Range. In many instances you don't want to change the physical order of
a source dataset simply to view or index it in a specific order. Sig
-----Original Message-----
From: Brian Vuong <brian-vuong@USA.NET> at Internet-E-Mail
Sent: Friday, November 10, 2000 1:29 PM
To: SAS-L@LISTSERV.UGA.EDU at Internet-E-Mail
Subject: Problems with sorting range
Hi Everyone,
I have a text field called Range. It looks like this:
Range
1-3
4-7
10-13
14-16
I have problems sorting this field because it would turn out to be like
this:
1-3
10-13
14-16
4-7
Is there any way I can either add zeros to 01-03 or better ways to this so I
can sort. I really appreciate any help.
Thanks,
Brian Vuong