BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Lav001
Fluorite | Level 6

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

 

1 ACCEPTED SOLUTION

Accepted Solutions
ballardw
Super User

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.

View solution in original post

3 REPLIES 3
ballardw
Super User

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.

Lav001
Fluorite | Level 6

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

ballardw
Super User

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.

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
  • 3 replies
  • 1924 views
  • 2 likes
  • 2 in conversation