LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous messageNext messagePrevious in topicNext in topicPrevious by same authorNext by same authorPrevious page (June 2009, week 4)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:   Mon, 22 Jun 2009 17:54:42 -0400
Reply-To:   Paul Dorfman <sashole@BELLSOUTH.NET>
Sender:   "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:   Paul Dorfman <sashole@BELLSOUTH.NET>
Subject:   Re: Alphabet function
Comments:   To: Kristin Graves <gravesk@CONED.COM>

Kristin,

The expression (assuming Version 9):

indexc (compress (put (collate (0,255), $256.),,"lk"), letter)

where LETTER is a 1-byte variable containing your lowcase letter will return each letter's lexicographic sequence starting with 1 regardless of the operating system's collating sequence (i.e. irrespective of ASCII or EBCDIC). To check, run the step below and observe the log:

data _null_ ; lowcase = compress (put (collate (0,255), $256.),,"lk") ; do i = 1 to 26 ; letter = char (lowcase, i) ; n = indexc (compress (put (collate (0,255), $256.),,"lk"), letter) ; put letter n 2.-R ; end ; run ;

An advantage of having V9 under the belt and using the relatively complex expression above is that you do not depend on [mis]typing the string "abcdefghijklmnopqrstuvwxyz". Of course, if this is a non-issue, then the primitive expression

indexc ("abcdefghijklmnopqrstuvwxyz", letter)

works under any version, at least from 6 to 9, and any collating sequence.

Kind regards ------------ Paul Dorfman Jax, FL ------------

On Mon, 22 Jun 2009 17:04:19 -0400, Kristin Graves <gravesk@CONED.COM> wrote:

>Is there a function that translates the (English) alphabet into the order >of the letters, i.e., a=1, b=2, c=3, etc? > >thanks, >Kristin Graves


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