Dear community,
I have been trying to apply the next formula in SAS:
b = (0.11852-0.05478*log(pd))^2.
Unfortunately, the log is giving me the following, not sure how to deal with it:
b = (0.11852-0.05478*log(pd))^2 _ 22 76 ERROR 22-322: Syntax error, expecting one of the following: ;, !, !!, &, *, **, +, -, /, <, <=, <>, =, >, ><, >=, AND, EQ, GE, GT, IN, LE, LT, NE, NOTIN, OR, ^<, ^=, ^>, |, ||, ~<, ~=, ~>. ERROR 76-322: Syntax error, statement will be ignored.
Could you please suggest?
Stefan
Your log message looks misaligned. Did you accidentally insert literal TAB characters into your source code?
379 data test; 380 pd=10; 381 b = (0.11852-0.05478*log(pd))^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. 382 put pd= b=; 383 run;
What did you think the ^ character would mean in that location?
The NOT operator is unary operator and not a binary operator.
Did you want to raise the value to the power of 2? If so use the ** operator.
384 data test; 385 pd=10; 386 b = (0.11852-0.05478*log(pd))**2. ; 387 put pd= b=; 388 run; pd=10 b=0.0000579975
Your log message looks misaligned. Did you accidentally insert literal TAB characters into your source code?
379 data test; 380 pd=10; 381 b = (0.11852-0.05478*log(pd))^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. 382 put pd= b=; 383 run;
What did you think the ^ character would mean in that location?
The NOT operator is unary operator and not a binary operator.
Did you want to raise the value to the power of 2? If so use the ** operator.
384 data test; 385 pd=10; 386 b = (0.11852-0.05478*log(pd))**2. ; 387 put pd= b=; 388 run; pd=10 b=0.0000579975
Show the entire Procedure or data step code, not just the line with the error.
Quite often some errors are caused by issues related to other lines above the reported problem.
The text of that message is sort of implying that an OPERATION is expected some where.
If I use a shorter line of code than you used I get this error:
12 data junk; 13 b = (0.11852-0.05478*log(pd))^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. 14 run;
Which indicates the problem is where the 2 appears.
You may need to use ** instead of ^ for exponentiation. ^ is a "not" operator.
15 data junk; 16 b = (0.11852-0.05478*log(pd))** 2; 17 run; NOTE: Variable pd is uninitialized. NOTE: Missing values were generated as a result of performing an operation on missing values. Each place is given by: (Number of times) at (Line):(Column). 1 at 16:22 1 at 16:23
No error, just note about no value for Pd, which is expected.
Please post the log of the whole statement, from the previous semicolon which ends the preceding statement up to the semicolon which ends this statement.
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 25. Read more here about why you should contribute and what is in it for you!
What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.
Find more tutorials on the SAS Users YouTube channel.