BookmarkSubscribeRSS Feed
ANIRBAN2
Fluorite | Level 6

I wanted to create table numeric which can store 22 digits and with decimals.

I need to create a table in proc sql only

and run insert query to enter the data.

Eg=123456789987654321.999

 

this is the numeric value.

 

14 REPLIES 14
Ksharp
Super User
NO. You can't .
But you could try PROC FEDSQL ,there is a BIGINT type variable.
ballardw
Super User

What exactly does that "number" represent with that many digits where a decimal is important?

ANIRBAN2
Fluorite | Level 6
That number is used at some where to calculate the VAR at retail banking. That I am not actually aware totally.
jklaverstijn
Rhodochrosite | Level 12

You could try and use explicit SQL pass-through. That way you use the SQL of the target DBMS. But that would only work if the large number is hardcoded in plain text or coming from another dbms table. It could not come from a SAS dataset. SAS' 8-byte numeric is either large magnitude or high precision but not both. Compare that to the 17-byte decimal in SQL Server. Can't fit round pins in square holes.

 

FedSQL may also be viable here but I have little experience go offer there.

 

Regards,

- Jan.

jklaverstijn
Rhodochrosite | Level 12
Ah you want it in SAS. Sorry my brain was talking database to me. 😉
Tom
Super User Tom
Super User

You cannot store that many digits of precision as a single number in a SAS dataset.  SAS has two variable types, fixed length character strings and 64 bit floating point numbers.  The maximum number of decimal digits you can store without lose of precision is 15.

 

Can you just store the value as a string of 22 (or perhaps 23 with the period?) characters?

string='123456789987654321.999';

Is the maximum absolute value just 10E18 like in your example and you only need three digits to the right of the decimal point?  Then you could store the first 11 to 15 digits in one number and the rest in another number. 

For example split the value into X and Y such that X+Y gets the desired value (if done in an environment that supports such precision).

x=123456789987000000.000;
y=000000000000654321.999;
ANIRBAN2
Fluorite | Level 6
I have the data in a excel I will write a insert query to upload the data into SAS datasets
So this method how will it work??
Already defined the table its variable name and datatype struggling when using insert query to upload the data. That time I wanted to change the length of the numerical variable so that i could fit the value with precision but I failed.


SASKiwi
PROC Star

Are you referring to retail banking Value at Risk (VaR) ? If so there is no way you need 22 digits of precision for this. At the very least this would be calculated as a whole number (no decimals) and 10 digits can accurately store up to $9,999,999,999. Please post the SAS log of your program so we can advise further.

ANIRBAN2
Fluorite | Level 6

ANIRBAN2_0-1656387004499.png

 

I just hope you can see as template provided by the company(Integrated)

SASKiwi
PROC Star

That screenshot shows no numbers more than 10 digits long. As others have said, SAS numeric variables can accurately hold 15 digits so I don't see what your problem is. You need to provide a log of your SAS program if it is producing errors and you want help with that.

ANIRBAN2
Fluorite | Level 6
I am in position of inputting sample data. Logs I cannot provide. Please view the snip.
SASKiwi
PROC Star

Surely you can run your program with fake data to produce the same errors? There shouldn't be anything confidential about that. 

Kurt_Bremser
Super User

Excel has the same precision limits as SAS, as it uses the same 8 byte floating point storage. So you can't precisely store a number with 22 digits in both environments.

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 14 replies
  • 1978 views
  • 1 like
  • 7 in conversation