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 (July 2002)Back to main SPSSX-L pageJoin or leave SPSSX-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Thu, 25 Jul 2002 07:14:34 -0400
Reply-To:     Raynald Levesque <rlevesque@videotron.ca>
Sender:       "SPSSX(r) Discussion" <SPSSX-L@LISTSERV.UGA.EDU>
From:         Raynald Levesque <rlevesque@videotron.ca>
Subject:      Re: identify substring (2 methods)
In-Reply-To:  <003601c23393$657523e0$64e96081@ssl.flinders.edu.au>
Content-Type: text/plain; charset="iso-8859-1"

Hi

******************. * This is one way. ******************. DATA LIST FIXED /str1 1-25 (A). BEGIN DATA Bloggs J 10 Smith St Bloggs John 12 Smith St END DATA. LIST.

VECTOR nb(25F1). LOOP cnt=1 TO 25. COMPUTE nb(cnt)=cnt*(1-NMISS(NUMBER(SUBSTR(str1,cnt,cnt),F1))). END LOOP. LOOP cnt=1 TO 25. IF nb(cnt)=0 nb(cnt)=$SYSMIS. END LOOP. COMPUTE pos=MIN(nb1 TO nb25).

STRING addr(A25). COMPUTE addr=SUBSTR(str1,pos).

*Clean up. ADD FILES FILE=* /DROP=pos nb1 TO nb25 cnt.

**************. *This is a more efficient method. **************. DATA LIST FIXED /str1 1-25 (A). BEGIN DATA Bloggs J 10 Smith St Bloggs John 12 Smith St END DATA. LIST.

VECTOR #nb(25F1). LOOP #cnt=1 TO 25. END LOOP IF #cnt*(1-NMISS(NUMBER(SUBSTR(str1,#cnt),F1)))>0.

STRING addr(A25). COMPUTE addr=SUBSTR(str1,#cnt). EXECUTE.

Raynald Levesque rlevesque@videotron.ca Visit my SPSS Pages http://pages.infinit.net/rlevesqu/index.htm

-----Original Message----- From: SPSSX(r) Discussion [mailto:SPSSX-L@LISTSERV.UGA.EDU]On Behalf Of Lisel O'Dwyer Sent: July 25, 2002 12:26 AM To: SPSSX-L@LISTSERV.UGA.EDU Subject: Re: identify substring

Hi Ray

thanks for this - but I don't seem to get the position of the first digit, if that is what the COMPUTE statement is designed to do. It just gives the length of the original string plus 1. So something must be wrong in the COMPUTE, but what?!

> Hi > > I do not have the time to finish it but this gives you the position of the > first digit. > > DATA LIST FIXED /str1 1-25 (A). > BEGIN DATA > Bloggs J 10 Smith St > Bloggs John 10 Smith St > END DATA. > LIST. > > VECTOR nb(25F1). > LOOP cnt=1 TO 25. > COMPUTE nb(cnt)=cnt*(1-NMISS(NUMBER(SUBSTR(str1,cnt,cnt),F1))). > END LOOP. > > Raynald Levesque rlevesque@videotron.ca > Visit my SPSS Pages http://pages.infinit.net/rlevesqu/index.htm > > > -----Original Message----- > From: SPSSX(r) Discussion [mailto:SPSSX-L@LISTSERV.UGA.EDU]On Behalf Of > Lisel O'Dwyer > Sent: July 24, 2002 5:07 AM > To: SPSSX-L@LISTSERV.UGA.EDU > Subject: identify substring > > > Hi all > > I'm still working with names and addresses (aargh!) > > Now I need to find the name part of a string consisting of name and address. > > eg "Bloggs J 10 Smith St" > > needs to be two variables, "Bloggs J" and "10 Smith St". > > The obvious answer is to use the location of the first numeric character to > split the string (create a substring from position 1 to -1 position of > numeric. > > But I'm having trouble actually working out the syntax for it! > > Any ideas? Thanks! > > Liel > Dr Lisel O'Dwyer > > School of Geography, Population and Environmental Management > Flinders University > GPO Box 2100 > Adelaide, South Australia 5001 > http://www.ssn.flinders.edu.au/geog/staff/odwyer.htm > IAG home page: http://www.ssn.flinders.edu.au/geog/iag/ > Telephone 61 8 8201 2969 > Fax 61 8 8201 3521 >


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