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.
You can store the number, but only with precision down to the 15th digit (overall). The imprecision is statistically insignificant.
What exactly does that "number" represent with that many digits where a decimal is important?
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.
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;
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.
I just hope you can see as template provided by the company(Integrated)
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.
Surely you can run your program with fake data to produce the same errors? There shouldn't be anything confidential about that.
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.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 16. Read more here about why you should contribute and what is in it for you!
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.
Select SAS Training centers are offering in-person courses. View upcoming courses for: