Date: Thu, 2 Oct 2003 08:38:20 +0200
Reply-To: Anders Mørup Jensen <amo@SSI.DK>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Anders Mørup Jensen <amo@SSI.DK>
Organization: TDC Totalloesninger
Subject: Re: index function
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
|