Inserting zeros using SPSS Syntax

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Inserting zeros using SPSS Syntax

J. Lerner
Our office received multiple excel files with ID numbers that are suppose
to be nine numbers long.  Apparently, there are some ID's that are less
than nine numbers long.

Is there a way I can use SPSS syntax to insert "0"s infront of the ID's
that are less than nine numbers long. Thank you.

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (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
Reply | Threaded
Open this post in threaded view
|

Re: Inserting zeros using SPSS Syntax

Richard Ristow
At 11:55 AM 6/11/2008, J. Lerner wrote:

>Our office received multiple excel files with ID numbers that are
>suppose to be nine numbers long.  Is there a way I can use SPSS
>syntax to insert "0"s infront of the ID's that are less than nine
>numbers long. Thank you.

This one comes up from time to time. The answer is, an SPSS number
can't *have* leading "0"s, or lack them either; SPSS numbers are
stored in a binary floating-point form. For your purpose, there are
two choices:

a. Set ID numbers' format so they *display* as 9 digits with leading
"0"s (the numbers themselves are unaltered). If the variable is named 'ID', use

FORMATS ID (N9).

b. Make the ID a character string rather than a number. You can do this:

STRING  ID_Char (A9).
COMPUTE ID_Char=NUMBER(ID,N9).


Note that both use the 'N9' format.

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (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
Reply | Threaded
Open this post in threaded view
|

Re: Inserting zeros using SPSS Syntax

Oliver, Richard
In reply to this post by J. Lerner
Use the N format, as in:
 
formats varname (n9).

________________________________

From: SPSSX(r) Discussion on behalf of J. Lerner
Sent: Wed 6/11/2008 10:55 AM
To: [hidden email]
Subject: Inserting zeros using SPSS Syntax



Our office received multiple excel files with ID numbers that are suppose
to be nine numbers long.  Apparently, there are some ID's that are less
than nine numbers long.

Is there a way I can use SPSS syntax to insert "0"s infront of the ID's
that are less than nine numbers long. Thank you.

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (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
[hidden email] (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