Truncation Question

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

Truncation Question

Ryan
This seems like it should be so easy, but just can't figure it out.

Here's an illustration of my dataset:

zipcode
34562
34571
45356
45389
04526
04533
.
.

The data are in numeric format. I want to convert these 5-digit ZIP
codes into 3-digit ZIP codes:

zipcode
345
345
453
453
045
045
.
.

In other words, I want to keep the first 3 digits of the 5 digit numbers.

Sorry for the silly question, but I can't seem to find the solution.

Ryan

=====================
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: Truncation Question

Ryan
Received a tip offline to convert to string, strip the last two
numbers and convert back. Thanks. -Ryan

On Sun, Oct 23, 2011 at 2:28 PM, R B <[hidden email]> wrote:

> This seems like it should be so easy, but just can't figure it out.
>
> Here's an illustration of my dataset:
>
> zipcode
> 34562
> 34571
> 45356
> 45389
> 04526
> 04533
> .
> .
>
> The data are in numeric format. I want to convert these 5-digit ZIP
> codes into 3-digit ZIP codes:
>
> zipcode
> 345
> 345
> 453
> 453
> 045
> 045
> .
> .
>
> In other words, I want to keep the first 3 digits of the 5 digit numbers.
>
> Sorry for the silly question, but I can't seem to find the solution.
>
> Ryan
>

=====================
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: Truncation Question

David Marso
Administrator
Ryan,
COMPUTE newzip=TRUNC(zipcode/100).
HTH, David

R B wrote
Received a tip offline to convert to string, strip the last two
numbers and convert back. Thanks. -Ryan

On Sun, Oct 23, 2011 at 2:28 PM, R B <[hidden email]> wrote:
> This seems like it should be so easy, but just can't figure it out.
>
> Here's an illustration of my dataset:
>
> zipcode
> 34562
> 34571
> 45356
> 45389
> 04526
> 04533
> .
> .
>
> The data are in numeric format. I want to convert these 5-digit ZIP
> codes into 3-digit ZIP codes:
>
> zipcode
> 345
> 345
> 453
> 453
> 045
> 045
> .
> .
>
> In other words, I want to keep the first 3 digits of the 5 digit numbers.
>
> Sorry for the silly question, but I can't seem to find the solution.
>
> Ryan
>

=====================
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
Please reply to the list and not to my personal email.
Those desiring my consulting or training services please feel free to email me.
---
"Nolite dare sanctum canibus neque mittatis margaritas vestras ante porcos ne forte conculcent eas pedibus suis."
Cum es damnatorum possederunt porcos iens ut salire off sanguinum cliff in abyssum?"
Reply | Threaded
Open this post in threaded view
|

Re: Truncation Question

Ryan
Efficient! Thank you. -Ryan

On Sun, Oct 23, 2011 at 3:36 PM, David Marso <[hidden email]> wrote:

> Ryan,
> COMPUTE newzip=TRUNC(zipcode/100).
> HTH, David
>
>
> R B wrote:
>>
>> Received a tip offline to convert to string, strip the last two
>> numbers and convert back. Thanks. -Ryan
>>
>> On Sun, Oct 23, 2011 at 2:28 PM, R B &lt;ryan.andrew.black@&gt; wrote:
>>> This seems like it should be so easy, but just can't figure it out.
>>>
>>> Here's an illustration of my dataset:
>>>
>>> zipcode
>>> 34562
>>> 34571
>>> 45356
>>> 45389
>>> 04526
>>> 04533
>>> .
>>> .
>>>
>>> The data are in numeric format. I want to convert these 5-digit ZIP
>>> codes into 3-digit ZIP codes:
>>>
>>> zipcode
>>> 345
>>> 345
>>> 453
>>> 453
>>> 045
>>> 045
>>> .
>>> .
>>>
>>> In other words, I want to keep the first 3 digits of the 5 digit numbers.
>>>
>>> Sorry for the silly question, but I can't seem to find the solution.
>>>
>>> Ryan
>>>
>>
>> =====================
>> To manage your subscription to SPSSX-L, send a message to
>> LISTSERV@.UGA (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
>>
>
>
> --
> View this message in context: http://spssx-discussion.1045642.n5.nabble.com/Truncation-Question-tp4930087p4930232.html
> Sent from the SPSSX Discussion mailing list archive at Nabble.com.
>
> =====================
> 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