BookmarkSubscribeRSS Feed
Hanyu
Obsidian | Level 7

I have a problem of computing numerical derivative using finite difference method. Obviously, I have to concern two problems, the rounding error and truncation error. The truncation error can be dealt by extrapolation. But the rounding error problem has something to do with machine accuracy and finding the proper scale of perturbation. This probably related to the fundamental of SAS, ie. how the number is stored in SAS and how SAS executes C language. I have already read numerical recipes in C. But I don't know how to apply the method to SAS. Any comment is truly appreciated. Thank you in advance.

3 REPLIES 3
Reeza
Super User

Borrowing a response from

It is an Intel issue not microsoft or SAS or any other program. There is even an IEE-standard.

IEEE floating point - Wikipedia, the free encyclopedia

floating point double-precision is what Intel is using as standard at the moment. Precision is 15 digits.

SAS(R) 9.2 Companion for Windows, Second Edition

Welcome in the digital age and the caveats.

"There are 10 types of people in the world; those that understand BINARY and those that do not"..  

Hanyu
Obsidian | Level 7

Thanks Reeza. Now I want to follow the book Numerical Recipe in C to reduce the round off error. In its 3rd edition page 230, it says one needs to use the trick temp=x+h

        donothing(temp)

     h=temp-x

to achieve the exact h. Any idea how to apply this trick in SAS?

Rick_SAS
SAS Super FREQ

To understand more about floating-point arithmetic, see the paper "What Every Computer Scientist Should Know About Floating-Point Arithmetic."

If you are doing numerical analysis in SAS, you should look at the SAS/IML language. The SAS/IML language supports numerical integration, differentiation, optimization, matrix computations, and other operations covered in Numerical Recipes. There is even a separate SAS/IML Support Community for questions about numerical operations.

Here are a few blog posts about numerical differentiation (also call finite differencing):

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 3 replies
  • 2520 views
  • 0 likes
  • 3 in conversation