Date: Tue, 2 Oct 2007 16:55:08 0700
ReplyTo: Hal 9000 <9000.hal@gmail.com>
Sender: "SPSSX(r) Discussion" <SPSSXL@LISTSERV.UGA.EDU>
From: Hal 9000 <9000.hal@gmail.com>
Subject: Re: breaking up (a string variable) is hard to do
InReplyTo: <f7e91e6d0710021653j6d8388denc8c543a54f2863b1@mail.gmail.com>
ContentType: text/plain; charset=ISO88591
oops, better make this:
> compute icd9_1 = concat(a, '', substr(b, 1, index(b, '')  1)).
this:
compute icd9_1 = concat(rtrim(a), '', rtrim(substr(b, 1, index(b, '')  1))).
;)
On 10/2/07, Hal 9000 <9000.hal@gmail.com> wrote:
> I wiped the tears from my eyes and came up with this (~sniff):
>
> * sample data *.
> data list free /icd9 (a13).
> begin data
> '305100567 '
> '4779000134 '
> '7999050259 '
> '8470010232 '
> '07800007 '
> '61171 167'
> end data.
>
> string a (a5) b (a7) icd9_1 (a8).
> compute b = substr(icd9, index(icd9, '') + 1).
> compute a = substr(icd9, 1, index(icd9, '')  1).
> compute icd9_1 = concat(a, '', substr(b, 1, index(b, '')  1)).
> exe.
>
> Gary
>
>
> On 10/2/07, Tanya Temkin <Tanya.L.Temkin@kp.org> wrote:
> > Hello all,
> >
> > I've been trying to chop up a string variable called ICD9_1 whose values
> > look like this:
> >
> > 305100567
> > 4779000134
> > 7999050259
> > 8470010232
> > 07800007
> > 61171 167
> >
> > *The number of digits (and, sometimes, blank spaces) before the second
> > hyphen varies.
> > * There are always three spaces between 1st and 2nd hyphen  if these
> > don't have numbers, they are padded with blanks.
> > * There are one to three digits after second hyphen.
> >
> > I want to set up a new variable that has all the digits before the second
> > hyphen, so I went:
> > string ICD9_1cd (A9).
> > compute ICD9_1cd=substr(ICD9_1,1,rindex(ICD9_1,"")1).
> >
> > and I get my variable but also an error message that says
> > >Warning # 606
> > >The third argument to SUBSTR (the length) is missing or is otherwise
> > >invalid. The argument must be a nonnegative integer. The result has
> > been
> > >set to the null string.
> >
> > In fact, I get a whole slew of these warnings, one for each case in my
> > file, up to the point where I am warned that the limit of mxwarnings in
> > the data pass has been reached and I won't get any more.
> >
> > I've seen similar syntax posted here before using INDEX and RINDEX in the
> > third argument in a substring expression. What's the problem here? Is
> > there a better way to do this?
> >
> > Thanks in advance,
> >
> > Tanya Temkin
> > Research Associate
> > AACC Reporting
> > Northern California Regional Office
> > The Permanente Medical Group
> > (510) 6256680
> >
> > NOTICE TO RECIPIENT: If you are not the intended recipient of this
> > email, you are prohibited from sharing, copying, or otherwise using or
> > disclosing its contents. If you have received this email in error,
> > please notify the sender immediately by reply email and permanently
> > delete this email and any attachments without reading, forwarding or
> > saving them. Thank you.
> >
>
