LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous (more recent) messageNext (less recent) messagePrevious (more recent) in topicNext (less recent) in topicPrevious (more recent) by same authorNext (less recent) by same authorPrevious page (November 2000, week 2)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
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
Comments: To: Brian Vuong <brian-vuong@USA.NET>
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


Back to: Top of message | Previous page | Main SAS-L page