Just tried Richard's original, but it generated an error. 
 

COMPUTE #Buffer=LTRIM (Input).

Error # 4285 in column 24. Text: Input

Incorrect variable name: either the name is more than 64 characters, or it is

not defined by a previous command.

Execution of this command stops.

Tried again with a couple of variations, but new variables contain only sysmis.  Perhaps I should have said I'm reading from a *.sav file and the variable to split is called student.
 
Will do Kylie's as well: give me some practice in logic.
 
----- Original Message -----
From: John F Hall
To: kylie.lange@adelaide.edu.au ; spssx-l@listserv.uga.edu
Sent: Tuesday, September 14, 2010 9:35 AM
Subject: Re: Re: Splitting a string

Kylie, Richard
 
Barely had time to get my breakfast and already 2 solutions.  Richard's will save some complex arithmetic, but Kylie's syntax will come in handy should I need something similar in future.  Always something new to learn!
 
Mille fois merci.
 
John
----- Original Message -----
From: Kylie Lange
To: SPSSX-L@LISTSERV.UGA.EDU
Sent: Tuesday, September 14, 2010 8:05 AM
Subject: Re: Splitting a string


Hi John,

If it is always the last three characters of the string that hold the digits
you need, then the following should create the numeric variable you can do
the arithmetic on:

COMPUTE y=NUMBER(CHAR.SUBSTR(str,CHAR.LENGTH(str)-2),f8).

Cheers,
Kylie.


-----Original Message-----
From: SPSSX(r) Discussion [mailto:SPSSX-L@LISTSERV.UGA.EDU] On Behalf Of
John F Hall
Sent: Tuesday, 14 September 2010 3:23 PM
To: SPSSX-L@LISTSERV.UGA.EDU
Subject: Splitting a string

Not often I ask for advice, but I am helping someone out with a data set
which has a string variable that needs splitting.  The strings consist of
one letter ot two, followed by three digits, each of which indicates
something different.  I've sorted the letter codes manually, but I still
need to generate three new variables, one for each digit eg:

f502       5 0 2
f503       5 0 3
f504       5 0 2
f521       5 2 1
fy101     1 0 1
fy102     1 0 2
fy111     1 1 1
fy121     1 2 1

I could do it manually in the Data Editor by scrolling down and deleting the
letters  then creating three variables arithmetically with

compute x = trunc (y/100)
compute z = mod (y/10)

etc etc, but someone out there will have a much neater solution.

John Hall
johnfhall@orange.fr
http://surveyresearch.weebly.com

=====================
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

=====================
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