call symput('theta',arcos(Variable1));
I was trying to compute the arcos of Variable1, whose value is much greater than 1.
Obviously, any value gt 1 is not a valid input argument for the function arcos() . I wonder if there is any clever way to bypass the restriction?
While on the subject, can I assign complex value to a variable in SAS?
SAS does not have built-in support for complex-valued analysis. There are a few instances where complex number arise in statistics (mostly time series and eigenvalues) but most SAS functions take real arguments. If you want to use complex values, you might want to consider symbolic math software such as Mathematica.
You can, of course, do these computations in SAS by defining your own functions, but it will be a pain. You can define the trig, arc-trig, and hyperbolic trig functions for complex numbers, but they are complicated and multivalued. You have to choose Principal Values to get an actual function.
What do you mean bypass? What do you want arcos(2) to be?
As for complex numbers, SAS/IML is used. Lots of material if you do a web search like sas complex number
I see. My maths are too old...
Maybe @Rick_SAS would be able to help?
SAS does not have built-in support for complex-valued analysis. There are a few instances where complex number arise in statistics (mostly time series and eigenvalues) but most SAS functions take real arguments. If you want to use complex values, you might want to consider symbolic math software such as Mathematica.
You can, of course, do these computations in SAS by defining your own functions, but it will be a pain. You can define the trig, arc-trig, and hyperbolic trig functions for complex numbers, but they are complicated and multivalued. You have to choose Principal Values to get an actual function.
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.
Ready to level-up your skills? Choose your own adventure.