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 (September 2010)Back to main SPSSX-L pageJoin or leave SPSSX-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Thu, 9 Sep 2010 23:18:17 -0400
Reply-To:     David Marso <david.marso@GMAIL.COM>
Sender:       "SPSSX(r) Discussion" <SPSSX-L@LISTSERV.UGA.EDU>
From:         David Marso <david.marso@GMAIL.COM>
Subject:      Re: Syntax to extract/convert numbers and strings from string
              variable

Hi Mike, Check: http://listserv.uga.edu/cgi-bin/wa?A2=ind9606&L=spssx-l&P=R9609&D=0 Put this in your pipe and smoke it !! ;-) I posted that gem over 14 years ago ;-)))) You'll need to fiddle with it to fit your situation but the basic idea is applicable. HTH, David

* General Parser *. DATA LIST / X 1-80 (A). BEGIN DATA 11-0101-423-7384 END DATA.

VECTOR NUMS(10). COMPUTE #0=0. LOOP. COMPUTE #1=INDEX(X,'-'). COMPUTE #0=#0+1. IF #1>0 NUMS(#0)=NUMBER(SUBSTR(X,1,#1-1),F8). COMPUTE X=SUBSTR(X,#1+1). END LOOP IF #1=0. COMPUTE NUMS(#0)=NUMBER(X,F8). MATCH FILES FILE * / DROP X. LIST.

NUMS1 NUMS2 NUMS3 NUMS4 NUMS5 NUMS6 NUMS7 NUMS8 NUMS9 NUMS10

11.00 101.00 423.00 7384.00 .

===================== To manage your subscription to SPSSX-L, send a message to LISTSERV@LISTSERV.UGA.EDU (not to SPSSX-L), with no body text except the command. To leave the list, send the command SIGNOFF SPSSX-L For a list of commands to manage subscriptions, send the command INFO REFCARD


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