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 (February 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 Feb 2005 20:26:48 +0100
Reply-To:   Jan Selchau-Hansen <jan@SELCHAU-HANSEN.INVALID>
Sender:   "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:   Jan Selchau-Hansen <jan@SELCHAU-HANSEN.INVALID>
Organization:   TDC Totalloesninger
Subject:   Re: Conditional statement based on values numeric or character

"Joan A" <joanab1970@YAHOO.COM> wrote in message news:20050216184857.65585.qmail@web31009.mail.mud.yahoo.com... > Hello, > > I would be very grateful for assistance with the following tasks. > > I created a new column called GROUPING that should be populated as Vendor > if the first digit in the code is alpha. If the first digit is a number, > then it is a Supplier. See code below. > > Thank you very much!! > Joan > > DATA testd.Target; > SET test; > length GROUPING $ 30; > IF substr(CODE,1,1) = <<a letter A_Z >> THEN GROUPING ='Vendor'; > IF substr(CODE,1,1) = <<a number 1-9 >> THEN GROUPING ='Supplier'; > RUN; > QUIT;

There are several different solutions ...

ex. IF upcase(substr(CODE,1,1)) in('A','B','C' .........) then GROUPING ='Vendor'; else grouping ='Supplier' ;

could be "reversed" like this IF input(substr(CODE,1,1)),1.) ne . then grouping = 'Suppiler'; else grouping='Vendor';

other options could be using either INDEX or INDEXC (both functions)

Jan


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