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 (March 2005, week 3)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Wed, 16 Mar 2005 16:20:23 -0500
Reply-To:     Lingqun Liu <lingqun@gmail.com>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         Lingqun Liu <lingqun@GMAIL.COM>
Subject:      Re: Conditional statement based on values numeric or character
Comments: To: "Schwarz, Barry A" <barry.a.schwarz@boeing.com>
In-Reply-To:  <AD11F90BB3FCF84C965D8F3E3BC66230269050@XCH-NW-26.nw.nos.boeing.com>
Content-Type: text/plain; charset=ISO-8859-1

Hi Barry, please try the revised code below (not tested on EBCDIC machine) see if it works.

--------------------------- sas code--------------------- * on ASCII machine 'A'<=fy<='z'; data _null_; y=';;bv'; length fy $1; fy=y; if '0'<=fy<='9' then grp='num '; else if 'A'<=fy<='z' then grp='char'; else grp='symb'; put _all_; run; * on EBCDIC machine 'a'<=fy<='Z' ; data _null_; y=';;bv'; length fy $1; fy=y; if '0'<=fy<='9' then grp='num '; else if 'a'<=fy<='Z' then grp='char'; else grp='symb'; put _all_; run; -----------------------------------end of sas code ---- Best, Lingqun

On Wed, 16 Feb 2005 14:03:46 -0800, Schwarz, Barry A <barry.a.schwarz@boeing.com> wrote: > Unfortunately, this doesn't work on EBCDIC machines. It also fails if > there can be punctuation marks or other special characters in position > one. > > -----Original Message----- > From: Lingqun Liu [mailto:lingqun@GMAIL.COM] > Sent: Wednesday, February 16, 2005 11:56 AM > To: SAS-L@LISTSERV.UGA.EDU > Subject: Re: Conditional statement based on values numeric or character > > One solution is using LENGTH statement and IF >'9' .... see the > following code. ------------------------------SAS > CODE---------------------------------------------------------- > data _null_; > x='1ab'; > y='Abv'; > length fx fy $1; > fx=x; > fy=y; > if fx<'9' then grp1='number'; > if fy>'9' then grpA='char'; > put _all_; > run; >


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