Converting long strings

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

Converting long strings

Jignesh Sutar
Why does the following syntax only pick up the first 16 character of the
string variable when attempting to convert it to a numeric?


NEW FILE.
DATA LIST LIST/ v1(A25).
BEGIN DATA.
1
12
123
1234
12345
123456
1234567
12345678
123456789
1234567890
12345678901
123456789012
1234567890123
12345678901234
123456789012345
1234567890123456
12345678901234567
123456789012345678
1234567890123456789
12345678901234567890
123456789012345678921
1234567890123456789212
END DATA.

STRING newvar(A99).
COMPUTE newvar=LTRIM(RTRIM(v1)).
COMPUTE newvar2 =NUMBER (newvar, F36.0).
EXE.

=====================
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: Converting long strings

Oliver, Richard
I believe this a function of operating system limitations.

-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of J Sutar
Sent: Friday, June 27, 2008 11:10 AM
To: [hidden email]
Subject: Converting long strings

Why does the following syntax only pick up the first 16 character of the
string variable when attempting to convert it to a numeric?


NEW FILE.
DATA LIST LIST/ v1(A25).
BEGIN DATA.
1
12
123
1234
12345
123456
1234567
12345678
123456789
1234567890
12345678901
123456789012
1234567890123
12345678901234
123456789012345
1234567890123456
12345678901234567
123456789012345678
1234567890123456789
12345678901234567890
123456789012345678921
1234567890123456789212
END DATA.

STRING newvar(A99).
COMPUTE newvar=LTRIM(RTRIM(v1)).
COMPUTE newvar2 =NUMBER (newvar, F36.0).
EXE.

=====================
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
Reply | Threaded
Open this post in threaded view
|

Re: Converting long strings

Peck, Jon
In reply to this post by Jignesh Sutar
You are converting a long string into a number.  Numbers on standard floating point hardware are limited to 16-17 digits of precision.  They cannot represent exact values with more digits than that.

SPSS preserves the most significant digits and calculates the magnitude of the number correctly, but you can't go beyond the limit of the hardware precision.

On the other hand, you could go up to magnitudes of 10** 308 :-)

HTH,
Jon Peck

-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of J Sutar
Sent: Friday, June 27, 2008 10:10 AM
To: [hidden email]
Subject: [SPSSX-L] Converting long strings

Why does the following syntax only pick up the first 16 character of the
string variable when attempting to convert it to a numeric?


NEW FILE.
DATA LIST LIST/ v1(A25).
BEGIN DATA.
1
12
123
1234
12345
123456
1234567
12345678
123456789
1234567890
12345678901
123456789012
1234567890123
12345678901234
123456789012345
1234567890123456
12345678901234567
123456789012345678
1234567890123456789
12345678901234567890
123456789012345678921
1234567890123456789212
END DATA.

STRING newvar(A99).
COMPUTE newvar=LTRIM(RTRIM(v1)).
COMPUTE newvar2 =NUMBER (newvar, F36.0).
EXE.

=====================
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
Reply | Threaded
Open this post in threaded view
|

Re: Converting long strings

Richard Ristow
In reply to this post by Jignesh Sutar
At 12:10 PM 6/27/2008, J Sutar wrote:

>Why does the following syntax only pick up the first 16 character of
>the string variable when attempting to convert it to a numeric?

As Richard Oliver wrote, "I believe this a function of operating
system limitations."

Which it is; or, if you prefer, it's a hardware limitation.
...........................................
Draft FAQ: Precision and range SPSS numbers

. Integers of up to 15 decimal digits can be represented exactly.

. However, the storage is not in decimal digits. Occasionally, two
non-integer quantities may not be 'equal' in SPSS comparison tests,
although they are identical as decimal numbers.

Numbers used as identifiers, therefore, should always be integers of
no more than 15 digits.

For calculation,

. The precision is very nearly equivalent to 16 decimal digits;

. Numbers can be between about 10**-308 and 10**308

DETAILS
-------
SPSS numbers use the 64-bit floating-point representation defined by
IEEE standard 754. It's a broadly suitable representation, and most
modern computers have hardware to do arithmetic with IEEE 754
numbers, so many applications use it.

Their precision is 53 bits, which is very close to 16 decimal digits. All
integers from 0 through 2**53 (9,007,199,254,740,992) can be
represented exactly (i.e., all through 15 digits, and most through 16
digits) can be represented, as can numbers as between 2**-1024 to
2**1024 (about 10**-308 and 10**308).



these numbers,



from 0 through 9,007,199,254,740,992 can be represented
exactly.  (i.e., all through 15
digits, and most through 16 digits)



The precision is 53 bits,





SPSS, and most current applications, represent numbers in the 64-bit
floating-point format defined by IEEE standard 754. Most modern
computers have hardware to do arithmetic with IEEE 754 numbers, so
calculations are fast and easy to program.

=====================
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
|

Why two R squares of Cubic Curves differ?

Juanito Talili
In reply to this post by Peck, Jon
Dear SPSS Users,
 
A scatter plot was created using the chart builder, afterwhich, using the chart editor a cubic curve was drawn (superimposed) across the scatterplot.  The R square of the cubic curve was 0.855.  Then, using the same dataset, a cubic model was run using the  curve estimation under the regression menu. The cubic regression model then yielded an R squared of 0.845.  I wonder why the two R squares (0.855 vs 0.845) differ? Your ideas are welcome!
 
Thank you.
J Talili




====================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: Converting long strings

Jignesh Sutar
In reply to this post by Richard Ristow
On 27/06/2008, Richard Ristow <[hidden email]> wrote:

>
> At 12:10 PM 6/27/2008, J Sutar wrote:
>
> Why does the following syntax only pick up the first 16 character of the
>> string variable when attempting to convert it to a numeric?
>>
>
> As Richard Oliver wrote, "I believe this a function of operating system
> limitations."
>
> Which it is; or, if you prefer, it's a hardware limitation.
> ...........................................
> Draft FAQ: Precision and range SPSS numbers
>
> . Integers of up to 15 decimal digits can be represented exactly.
>
> . However, the storage is not in decimal digits. Occasionally, two
> non-integer quantities may not be 'equal' in SPSS comparison tests, although
> they are identical as decimal numbers.
>
> Numbers used as identifiers, therefore, should always be integers of no
> more than 15 digits.
>
> For calculation,
>
> . The precision is very nearly equivalent to 16 decimal digits;
>
> . Numbers can be between about 10**-308 and 10**308
>
> DETAILS
> -------
> SPSS numbers use the 64-bit floating-point representation defined by IEEE
> standard 754. It's a broadly suitable representation, and most modern
> computers have hardware to do arithmetic with IEEE 754 numbers, so many
> applications use it.
>
> Their precision is 53 bits, which is very close to 16 decimal digits. All
> integers from 0 through 2**53 (9,007,199,254,740,992) can be represented
> exactly (i.e., all through 15 digits, and most through 16 digits) can be
> represented, as can numbers as between 2**-1024 to 2**1024 (about 10**-308
> and 10**308).
>
>
>
> these numbers,
>
>
>
> from 0 through 9,007,199,254,740,992 can be represented exactly.  (i.e.,
> all through 15
> digits, and most through 16 digits)
>
>
>
> The precision is 53 bits,
>
>
>
>
>
> SPSS, and most current applications, represent numbers in the 64-bit
> floating-point format defined by IEEE standard 754. Most modern
> computers have hardware to do arithmetic with IEEE 754 numbers, so
> calculations are fast and easy to program.
>
>
>
>

=====================
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