1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
* How to convert string to numeric variables.

* This is a note about implied decimals.
* Raynald Levesque 2003/02/23.

data list list /str1(a4).
begin data
1.2
20
end data.

/* no implied decimals (when there are no explicit decimal)*/ .
compute n0=number(str1,f4.0).

/* 1 implied decimal (when there are no explicit decimal)*/ .
compute n1=number(str1,f4.1).

/* 2 implied decimals (when there are no explicit decimal)*/ .
compute n2=number(str1,f4.2)	
LIST.

* This is the output:
STR1       N0       N1       N2

1.2      1.20     1.20     1.20
20      20.00     2.00      .20

* note how 20 is converted.