1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
*(Q) I have a variable that is in string format, 
	ie "120/90". I need to get this into a number format separating
	 the numbers on either side of the slash into 2 variables.  Any suggestions?

*(A) Posted to SPSSX-L list by Ray on 2002/01/05.

DATA LIST FIXED /nb 1-10 (A).
BEGIN DATA
120/90
1425/1
1/2
/3
23/
END DATA.
LIST.

* locate the position of the "/".
COMPUTE #pos=INDEX(nb,"/").

* Convert the 2 sub-strings into 2 numbers.
COMPUTE nb1=NUMBER(SUBSTR(nb,1,#pos-1),F8.0).
COMPUTE nb2=NUMBER(SUBSTR(nb,#pos+1),F8.0).
EXECUTE.