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 2007)Back to main SPSSX-L pageJoin or leave SPSSX-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Tue, 2 Oct 2007 16:55:08 -0700
Reply-To:     Hal 9000 <9000.hal@gmail.com>
Sender:       "SPSSX(r) Discussion" <SPSSX-L@LISTSERV.UGA.EDU>
From:         Hal 9000 <9000.hal@gmail.com>
Subject:      Re: breaking up (a string variable) is hard to do
Comments: To: Tanya.L.Temkin@kp.org
In-Reply-To:  <f7e91e6d0710021653j6d8388denc8c543a54f2863b1@mail.gmail.com>
Content-Type: text/plain; charset=ISO-8859-1

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 > '3051-005-67 ' > '4779-000-134 ' > '7999-050-259 ' > '8470-010-232 ' > '0780-000-7 ' > '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: > > > > 3051-005-67 > > 4779-000-134 > > 7999-050-259 > > 8470-010-232 > > 0780-000-7 > > 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 non-negative 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) 625-6680 > > > > NOTICE TO RECIPIENT: If you are not the intended recipient of this > > e-mail, you are prohibited from sharing, copying, or otherwise using or > > disclosing its contents. If you have received this e-mail in error, > > please notify the sender immediately by reply e-mail and permanently > > delete this e-mail and any attachments without reading, forwarding or > > saving them. Thank you. > > >


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