Date: Thu, 2 Oct 2003 09:49:20 -0400
Reply-To: "Fehd, Ronald J. (PHPPO)" <rjf2@CDC.GOV>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: "Fehd, Ronald J. (PHPPO)" <rjf2@CDC.GOV>
Subject: Re: When SUBSTR just won't do
Content-Type: text/plain
> TypeDosage=SEROQUEL TABS 25MG (no space here) MG=17 I=14
12345678901234567890
> 66 Dosage = input(substr(TypeDosage,I+1,MG-1)
should be:
> 66 Dosage = input(substr(TypeDosage,I+1,MG-I-1)
Ron Fehd the macro maven CDC Atlanta GA USA RJF2@cdc.gov
--> cheerful provider of slightly less than
UNTESTED SAS code from the Clue?Gee!Wrx <--
> -----Original Message-----
> From: Charles Patridge [mailto:charles_s_patridge@PRODIGY.NET]
> When I tried your untested solution here is what I got -
>
> 58 data test2;
> 59 set test;
> 60 TypeDosage = medication;
> 61
> 62 MG = index(TypeDosage,'MG');*returns column of MG;
> 63 if MG then do;
> 64 do I = MG-2 to 1 by -1
> 65 until(Space = ' '); Space = substr(TypeDosage,I,1);end;
> 66 Dosage = input(substr(TypeDosage,I+1,MG-1)
> 67 ,4.);*max dosage: 9999;
> 68 end;
> 69 else Dosage = .;
> 70
> 71 put Dosage;
> 72 run;
> NOTE: Invalid argument to function INPUT at line 66 column
> TypeDosage=SEROQUEL TABS 25MG (no space here) MG=17 I=14
|