1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
*(Q)How can I change numeric variable from format ".76" into format "0.76". ?

* (A) Posted by Ray to SPSSX-L list on 2002/08/30.
* For integers the N format can be used, but for numbers with decimals, strings must be used.

DATA LIST LIST /var1 int1.
BEGIN DATA
.45 	3
1.34 	10
END DATA.
LIST.

STRING var2(A4).
COMPUTE var2=LPAD(LTRIM(STRING(var1,F4.2)),4,"0").
FORMATS int1(N2).
LIST var2 int1.

* The result is:
VAR2 INT1

0.45  03
1.34  10

*