Hi,
When I tried to use power function in SAS EG 7.1 Version with below code, it is throwing below error:
Also, tried to use with CAPS/NOCAPS system option https://support.sas.com/kb/62/620.html
data test:
y=power(2,2);
z=power(2,2);
run;
error 68-185 the function power is unknown or cannot be accessed
Could you suggest on resolving above error.
Thanks
In SAS you would use the ** (yes 2 asterisks) .
3**2 is 9
3**0.5 would be the square root of 3 though there is a SQRT function specifically.
The ^ character is a logical "not" operator. I suspect you tried 2^2 and got a message like:
263 data junk; 264 x = 3 ^2; - 22 76 ERROR 22-322: Syntax error, expecting one of the following: <, <=, =, >, >=, EQ, GE, GT, LE, LT, NE, NG, NL, ^=, ~=. ERROR 76-322: Syntax error, statement will be ignored. 265 run;
Left as an exercise for the interested reader why
x = ^2;
does not throw an error. Hint: use different values like 0, 1, 2 and 3 and check the results.
Remember SAS only has two variable types, numeric and character and that might help.
What is the "power" function supposed to do? It sounds like you are trying to use the syntax from a different programming language.
The error is pretty clear: SAS does not supply a function named power.
If someone in your organization has written such using Proc Fcmp then it has not been set up for you to use.
I m trying to calculate below value, I thought Power can be sued.
Is there any other way to calculate below value?
(Age)^0.02
In SAS you would use the ** (yes 2 asterisks) .
3**2 is 9
3**0.5 would be the square root of 3 though there is a SQRT function specifically.
The ^ character is a logical "not" operator. I suspect you tried 2^2 and got a message like:
263 data junk; 264 x = 3 ^2; - 22 76 ERROR 22-322: Syntax error, expecting one of the following: <, <=, =, >, >=, EQ, GE, GT, LE, LT, NE, NG, NL, ^=, ~=. ERROR 76-322: Syntax error, statement will be ignored. 265 run;
Left as an exercise for the interested reader why
x = ^2;
does not throw an error. Hint: use different values like 0, 1, 2 and 3 and check the results.
Remember SAS only has two variable types, numeric and character and that might help.
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.
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.