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 (October 2003, week 1)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Thu, 2 Oct 2003 05:27:46 -0400
Reply-To:     Gerhard Hellriegel <ghellrieg@T-ONLINE.DE>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         Gerhard Hellriegel <ghellrieg@T-ONLINE.DE>
Subject:      Re: index function
Content-Type: text/plain; charset=ISO-8859-1

... and if you really want to find spaces:

create a dummy variable, assign the string to it, use substr(dummy,location- of-space-found) and assign the result to dummy. That you include in a loop until dummy=" "...

On Thu, 2 Oct 2003 08:38:20 +0200, Anders Mørup Jensen <amo@SSI.DK> wrote:

>Hello Kay > >I doubt that you are actually interested in finding the location of the >spaces. > >I think that you want to use the location of the spaces only to break down >the data lines into words. This is easily done by the function scan. > >e.g. scan(medication,2) will give you the second word in the medication >variable and scan(medication,-1) will give you the last word. > >Anders Mørup Jensen > >"Yang, Kai" <Kai.Yang@CSHS.ORG> skrev i en meddelelse >news:3CFAA0108952D111A5BF00805FA6FB0F05B602D9@PEDSNTAS.csmc.edu... >> hello,SAS-L: >> I would like to ask a index function question: >> >> data test; >> infile cards; >> input @1 medication $50.; >> cards; >> SEROQUEL TABS 100 MG >> SEROQUEL TABS 25MG (no space here) >> INJECTION: HALDOL DECANOATE 100 MG/ML >> INJECTION: HALOPERIDOL 2 MG/ML >> ; >> run; >> data _temp; >> set test; >> b=index(medication," "); >> run; >> >> After I run the program, the variable "b" would be a number of the first " >" >> location from left to right. >> Is there a way or function to give me the second or third " " location in >> data step? >> Thank you >> Kai


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