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

Can any one help me to resolve or fix the following syntax error:

 

ERROR 22-322: Syntax error, expecting one of the following: !, !!, &, (, ), *, **, +, ',', -, '.',
/, <, <=, <>, =, >, >=, ?, AND, BETWEEN, CONTAINS, EQ, EQT, GE, GET, GT, GTT, IN, IS,
LE, LET, LIKE, LT, LTT, NE, NET, NOT, NOTIN, OR, ^, ^=, |, ||, ~, ~=.
 
ERROR 76-322: Syntax error, statement will be ignored.
 
Thank you,
1 ACCEPTED SOLUTION

Accepted Solutions
Kurt_Bremser
Super User

So there are two separate errors.

The first is your use of the SQL AVG summary function. SQL summary functions need SQL expressions as arguments, and in SQL, variables must be separated by colons instead of spaces (as in a data step).

I also found that avg is only available for vertical use (one column over several records), for horizontal averaging (several columns in one record) you should use the mean() function.

So it should be

mean(Height,CMDS,CBSDL,CBSDS,CBSDRNharvest,SRNumber,SRMass,FSRYield,Groundbiomass,TBMass,Hindex,Dmcontent,BCarotene,PPD1w,PPD2w)

to make it syntactically correct.

The second error is the invocation of the macro %DialAnalFixModel, which is obviously not known to SAS at this stage. Make sure that a proper %include for the file where this macro is stored is in your program, or get the macro definition text and copy it into your program.

 

View solution in original post

3 REPLIES 3
Kurt_Bremser
Super User

Well, it is a syntax error, meaning that the code is erroneous. We cannot help you without the code. Please post the whole log of the offending step.

Athanase
Calcite | Level 5
proc sql;
create table import1 as
select I,J,ENTRY,avg(Height CMDS CBSDL CBSDS CBSDRNharvest SRNumber SRMass
FSRYield Groundbiomass TBMass Hindex Dmcontent BCarotene PPD1w PPD2w) as
avg_Y,AVGH
from import1
group by I,J,ENTRY;
title "Griffing model 1 method 4";
%DialAnalFixModel(NUM_P=6,method=4,Yvar=Height CMDS CBSDL CBSDS
CBSDRNharvest SRNumber SRMass FSRYield Groundbiomass TBMass Hindex
Dmcontent BCarotene PPD1w PPD2w,ENV=2,rep=3,dsn=import1);
run;
quit

results with error:

79 proc sql;
80 create table import1 as
81 select I,J,ENTRY,avg(Height CMDS CBSDL CBSDS CBSDRNharvest
SRNumber SRMass FSRYield Groundbiomass TBMass Hindex Dmcontent
____
22
76
81 ! BCarotene PPD1w PPD2w) as avg_Y,AVGH
ERROR 22-322: Syntax error, expecting one of the following: !, !!, &,
(, ), *, **, +, ',', -, '.', /, <, <=, <>, =, >, >=, ?, AND,
BETWEEN, CONTAINS, EQ, EQT, GE, GET, GT, GTT, IN, IS,
LE, LET, LIKE, LT, LTT, NE, NET, NOT, NOTIN, OR, ^, ^=, |, ||,
~, ~=.
ERROR 76-322: Syntax error, statement will be ignored.
82 from import1
83 group by I,J,ENTRY;
NOTE: PROC SQL set option NOEXEC and will continue to check the
syntax of statements.
84 title "Griffing model 1 method 4";
WARNING: Apparent invocation of macro DIALANALFIXMODEL not resolved.
85 %DialAnalFixModel(NUM_P=6,method=4,Yvar=Height CMDS CBSDL
CBSDS CBSDRNharvest SRNumber SRMass FSRYield Groundbiomass
_
180
85 ! TBMass Hindex Dmcontent BCarotene PPD1w
PPD2w,ENV=2,rep=3,dsn=import1);
ERROR 180-322: Statement is not valid or it is used out of proper order.
86 run;
NOTE: PROC SQL statements are executed immediately; The RUN statement
has no effect.
87 quit
88
89 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
NOTE: The SAS System stopped processing this step because of errors.
NOTE: PROCEDURE SQL used (Total process time):
real time 0.01 seconds
cpu time 0.02 seconds



##- Please type your reply above this line. Simple formatting, no
attachments. -##
Kurt_Bremser
Super User

So there are two separate errors.

The first is your use of the SQL AVG summary function. SQL summary functions need SQL expressions as arguments, and in SQL, variables must be separated by colons instead of spaces (as in a data step).

I also found that avg is only available for vertical use (one column over several records), for horizontal averaging (several columns in one record) you should use the mean() function.

So it should be

mean(Height,CMDS,CBSDL,CBSDS,CBSDRNharvest,SRNumber,SRMass,FSRYield,Groundbiomass,TBMass,Hindex,Dmcontent,BCarotene,PPD1w,PPD2w)

to make it syntactically correct.

The second error is the invocation of the macro %DialAnalFixModel, which is obviously not known to SAS at this stage. Make sure that a proper %include for the file where this macro is stored is in your program, or get the macro definition text and copy it into your program.

 

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

SAS Enterprise Guide vs. SAS Studio

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.

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
  • 3357 views
  • 0 likes
  • 2 in conversation