Desktop productivity for business analysts and programmers

format of numeric variable 30 digits long, no comma

Accepted Solution Solved
Reply
Contributor
Posts: 71
Accepted Solution

format of numeric variable 30 digits long, no comma

Hello,

I got a numeric variable extracted from the Oracle DB that is set to numeric 8.

But the variable should be able to store 30 digits not just 18 or 19.

What would be the correct format that I need to apply?

I looked around for input and COMMA but that just created decimals.

Thanks for any help.


Accepted Solutions
Solution
‎12-29-2016 08:18 AM
Super User
Posts: 5,369

Re: format of numeric variable 30 digits long, no comma

Using SAS, you will have to bring in the field as character.  It's not a matter of finding a format (or an informat).  It's that SAS cannot accurately store numbers that large.  So even if you find a way to bring it in as numeric, SAS will change the value.

View solution in original post


All Replies
Solution
‎12-29-2016 08:18 AM
Super User
Posts: 5,369

Re: format of numeric variable 30 digits long, no comma

Using SAS, you will have to bring in the field as character.  It's not a matter of finding a format (or an informat).  It's that SAS cannot accurately store numbers that large.  So even if you find a way to bring it in as numeric, SAS will change the value.

Contributor
Posts: 71

Re: format of numeric variable 30 digits long, no comma

hmhmmm that is interesting. thanks
Respected Advisor
Posts: 4,137

Re: format of numeric variable 30 digits long, no comma

Unlike Oracle SAS has only two data types: Character and Numeric.

 

In SAS a length of 8 for a numeric variable doesn't mean 8 digits but that SAS uses 8 Bytes to store the value. This allows to store numbers with full precision up to 15 digits.

 

The only way to store more than 15 digits with full precision in SAS is to use a character variable - which is o.k. as long as you only use this data categorical and don't want to actually do calculations with it. Most of the time that's what such many digits are: Some ID or Account number or the like.

 

The conversion to character needs to happen on the database side - a cast() function with Oracle. If you use the table with these numeric(n) datatypes often then consider to create a view in Oracle and implement the cast() there; else use SQL pass-through or use option dbsastype http://support.sas.com/documentation/cdl/en/acreldb/69580/HTML/default/viewer.htm#n0v4ma1zb9lu99n172...

 

☑ This topic is solved.

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

Discussion stats
  • 3 replies
  • 288 views
  • 2 likes
  • 3 in conversation