Help using Base SAS procedures

numeric values weren't read correctly

Accepted Solution Solved
Reply
Contributor
Posts: 31
Accepted Solution

numeric values weren't read correctly

Hello,

Could someone help to explain why the numeric values were not read correctly?   Thank you!  Yvonne

data id;

  input id best32.;

  format id 20.;

datalines;

2416303039498861622

2416303543869862689

2416307785486124532

2416309804262141822

; run;

proc print; run;

------output--------

Obs                     id

1     2416303039498861568
2     2416303543869862912
3     2416307785486124544
4     2416309804262141952


Accepted Solutions
Solution
‎06-02-2015 12:11 AM
Super User
Posts: 3,252

Re: numeric values weren't read correctly

Your ID field is too long for SAS to hold accurately as a number - around 15 digits is the maximum. For ID-type fields read these as character to fix your problem:

input id $20.;

View solution in original post


All Replies
Solution
‎06-02-2015 12:11 AM
Super User
Posts: 3,252

Re: numeric values weren't read correctly

Your ID field is too long for SAS to hold accurately as a number - around 15 digits is the maximum. For ID-type fields read these as character to fix your problem:

input id $20.;

Contributor
Posts: 31

Re: numeric values weren't read correctly

Thank you!

But I have other tables with numeric ID (length 20.), this table was from 3rd party.  Does  it mean I need to convert others to a character ID?  Not very efficient but if there is no choice.

Super User
Posts: 3,252

Re: numeric values weren't read correctly

Unfortunately yes. In what form do you receive these tables? If they are delimited or fixed-length text files you may be able to read them in as character to begin with.

🔒 This topic is solved and locked.

Need further help from the community? Please ask a new question.

Discussion stats
  • 3 replies
  • 236 views
  • 1 like
  • 2 in conversation