|
Sorry, my first answer went to listserv adress.
Here'a another solution .... * =============================================. COMPUTE position = 1000 /*position of first number*/. LOOP #number = 0 TO 9 /*check positions for numbers 0 to 9 and chose earliest*/. IF (INDEX(name,STRING(#number,F1)) > 0 AND INDEX(name,STRING(#number,F1)) < position) position = INDEX(name,STRING(#number,F1)) /*0 is not allowed*/. END LOOP. STRING prefix number (A20). COMPUTE prefix = RTRIM(SUBSTR(name,1,position - 1)). COMPUTE number = RTRIM(SUBSTR(name,position)). LIST / VAR = name prefix number / CASES TO 10. * =============================================. Good luck, Mario ----- Ursprüngliche Mail ---- Von: Cheryl Scott <[hidden email]> An: [hidden email] Gesendet: Freitag, den 26. September 2008, 18:12:31 Uhr Betreff: substring I need to split several thousand course names into two parts: prefix and course number. The prefix is always first in the name and is comprised of alpha characters only.. The course number is second in the name and is mostly numeric although may contain an alpha trailing character. Example below (the name is what I have, prefix and number are what I want): name prefix number AAD100 AAD 100 AAD100B AAD 100B ENG090 ENG 090 DH290 DH 290 Is there a way to efficiently break the name into the 2 pieces that I need, perhaps based on the first occurrence of a number? Cheryl Scott IR Data Manager Office of Institutional Research Truckee Meadows Community College [hidden email] (775)673-8239 (w) ====================To manage your subscription to SPSSX-L, send a message to [hidden email] (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 __________________________________________________ Do You Yahoo!? Sie sind Spam leid? Yahoo! Mail verfügt über einen herausragenden Schutz gegen Massenmails.. http://mail.yahoo.com ====================To manage your subscription to SPSSX-L, send a message to [hidden email] (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
Mario Giesel
Munich, Germany |
| Free forum by Nabble | Edit this page |
