weird data import

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

weird data import

Marinica Barbulescu - Yahoo
 Dear list,


I have a numeric variable containing an 18 digits value: 100552558600045000 in a .txt file

When I’m importing this file in SPSS (version 15) the value becomes 100552558600044900 in the .sav file

The weirdest thing is that if I export the variable to a csv file, the value gets back to original, but if I export it to a fixed file, then the wrong values is exported.


Has anyone encountered the same issue?


Many thanks,


Marinica


Reply | Threaded
Open this post in threaded view
|

Re: weird data import

Richard Ristow
To the list members: I'm posting in plain text, because HTML in my
postings hasn't been being properly rendered in list distributions,
particularly in the archives.

At 12:31 PM 11/12/2010, Marinica Barbulescu - Yahoo wrote:

>I have a numeric variable containing an 18 digits value:
>100552558600045000 in a .txt file. When I import this file in SPSS
>(version 15) the value becomes 100552558600044900 in the .sav file

Your original number has more digits than SPSS can represent
completely. SPSS numbers are represented to 53 bits precision, a
little less than 16 digits.

The 53-bit value that's nearest your input value is
100552558600044992, and that seems to be what's actually in the .SAV
file (see Frst12dig and Last06dig), but for display SPSS seems to
truncate to the value you see:

DATA LIST LIST
  /BigText            BigValue
   (A18,              F18     ).
BEGIN DATA
   100552558600045000 100552558600045000
END DATA.
FORMATS BigValue  (COMMA25).


NUMERIC Frst12dig (COMMA16)
         Last06dig (COMMA07).

COMPUTE Last06dig=MOD(BigValue,1E6).
COMPUTE Frst12dig=(BigValue-Last06dig)/1E6.

LIST.

List
|-----------------------------|---------------------------|
|Output Created               |12-NOV-2010 16:51:31       |
|-----------------------------|---------------------------|
BigText                           BigValue       Frst12dig Last06dig

100552558600045000 100,552,558,600,044,900 100,552,558,600   44,992

Number of cases read:  1    Number of cases listed:  1

>The weirdest thing is that if I export the variable to a csv file,
>the value gets back to original, but if I export it to a fixed file,
>then the wrong values is exported.

These sound like oddities of how SPSS converts your internal value to
18 characters -- truncating to 16 digits in the fixed file, rounding
in the .csv file in a way that (accidentally) gave the original value.

=============================
APPENDIX: Test data, and code
=============================
DATA LIST LIST
  /BigText            BigValue
   (A18,              F18     ).
BEGIN DATA
   100552558600045000 100552558600045000
END DATA.
FORMATS BigValue  (COMMA25).


NUMERIC Frst12dig (COMMA16)
         Last06dig (COMMA07).

COMPUTE Last06dig=MOD(BigValue,1E6).
COMPUTE Frst12dig=(BigValue-Last06dig)/1E6.

LIST.
=====================================
Scratch code, used during development
=====================================
DATA LIST LIST
  /BigText  BigValue  BigConverted First12 Last6
   (A18,    F18,      F18,         2F12).
BEGIN DATA
   100552558600045000 100552558600045000 100552558600044900 100552558600 045000
END DATA.
FORMATS BigValue BigConverted (COMMA25)
         First12               (COMMA16)
         Last6                 (COMMA07).
LIST.

COMPUTE Recombine=First12*1E6 + Last6.
FORMATS Recombine (COMMA25).
LIST.

COMPUTE Drop12   =Recombine-First12*1E6.
FORMATS Drop12    (COMMA07).
LIST.
NUMERIC ExtFrst12 (COMMA16)
         ExtLast6  (COMMA07).
COMPUTE ExtLast6  =MOD(BigValue,1E6).
COMPUTE ExtFrst12 =(BigValue-ExtLast6)/1E6.
LIST.

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

Automatic reply: weird data import

Genevieve Odoom
Hello,
Thank you for your email. I will be out of the office on  Monday, November 15th, returning on Tuesday, November 16th and will respond to your message when i return.



Thanks!
Genevieve Odoom
Policy and Program Analyst
OANHSS
Suite 700 - 7050 Weston Rd. Woodbridge,
ON L4L 8G7
Tel: (905) 851-8821 x 241 Fax: (905) 851-0744
[hidden email]
www.oanhss.org<https://mail.oanhss.org/ecp/Organize/www.oanhss.org>

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