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
*(Q) I need to retain the leading zeros of zip codes when I import my Excel data
file into SPSS.  Can you tell me how to do this?   When SPSS opens my Excel
data file, the leading zeros are lost.  I need them in order to merge 2
files.


*(A) Since you need the leading zeros to match, it means your zip codes are
strings. The following code converts numbers into strings with leading
zeros.
* Posted to SPSSX-L lsit by Raynald Levesque on 2002/03/12.

* Data example.
DATA LIST LIST /zipnum.
BEGIN DATA
2
125
2364
62514
END DATA.
LIST.

* Conversion.
STRING zip(A5).
COMPUTE zip=STRING(zipnum,N5).
LIST.

* The out put is as follows:.
  ZIPNUM ZIP

    2.00 00002
  125.00 00125
 2364.00 02364
62514.00 62514