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:
>I doubt that you are actually interested in finding the location of the
>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
>> I would like to ask a index function question:
>> data test;
>> infile cards;
>> input @1 medication $50.;
>> SEROQUEL TABS 100 MG
>> SEROQUEL TABS 25MG (no space here)
>> INJECTION: HALDOL DECANOATE 100 MG/ML
>> INJECTION: HALOPERIDOL 2 MG/ML
>> data _temp;
>> set test;
>> b=index(medication," ");
>> After I run the program, the variable "b" would be a number of the
>> location from left to right.
>> Is there a way or function to give me the second or third " " location in
>> data step?
>> Thank you