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

I'm working on some generalized linear models, and for NLMIXED estimate statements I want to create temporary variables so that I don't have to invert the link function every time again. When multiplying a continuous parameter with a scalar without using parentheses this results in a syntax error though, as demonstrated in this example code:

 

proc nlmixed data=sashelp.class;
   parms b0=0 b1=0 sigma=1;
   mu = b0 + age*b1;
   model weight ~ normal(mu, sigma);
   
   age15 = b0 + 15*b1;     /* Crashes at '+ 15' */
   age15 = b0 + (15*b1);   /* Works */
   age15 = 15*b1 + b0;     /* Works */
   estimate "Weight at age 15" age15;
   estimate "Weight at age 15" b0 + 15*b1; /* Works */
run;

ERROR 22-322: Syntax error, expecting one of the following: !, !!, &, ...

Is there any reason why the first statement doesn't work, while all of the other are fine (including that exact same syntax inside an estimate statement)?

1 ACCEPTED SOLUTION

Accepted Solutions
FreelanceReinh
Jade | Level 19

Hello @pblls,

 

I think nothing is wrong with the syntax and the fact that the compiler doesn't accept an expression followed by a plus or minus sign and a number (e.g. 0+0) in this place is just a bug. Thank you for notifying the community of the bug and the workarounds you've found (also inserting another plus sign seems to work: 0++0).

 

The most recent list of "Issues Addressed in SAS 9.4 (TS1M8)" is quite long and includes four items about PROC NLMIXED, but this new bug should be worth adding. So you may want to report it to SAS Technical Support.

View solution in original post

5 REPLIES 5
PaigeMiller
Diamond | Level 26

Please show us the entire log for this PROC. Never show us ERROR messages and not show us the rest of the log for that PROC.

--
Paige Miller
pblls
Calcite | Level 5

Sure, I figured that was the relevant part, here's the full log:

 

1    proc nlmixed data=sashelp.class;
2       parms b0=0 b1=0 sigma=1;
3       mu = b0 + age*b1;
4       model weight ~ normal(mu, sigma);
5
6       age15 = b0 + 15*b1;     /* Crashes at '+ 15' */
                   ---
                   22
                   76
ERROR 22-322: Syntax error, expecting one of the following: !, !!, &, (, *, **, +, -, /, <, <=,
              <>, =, >, ><, >=, AND, EQ, GE, GT, LE, LT, NE, OR, [, ^<, ^=, ^>, {, |, ||, ~<, ~=,
              ~>.
ERROR 76-322: Syntax error, statement will be ignored.
7       age15 = b0 + (15*b1);   /* Works */
8       age15 = 15*b1 + b0;     /* Works */
9       estimate "Weight at age 15" age15;
10      estimate "Weight at age 15" b0 + 15*b1; /* Works */
11   run;

NOTE: The SAS System stopped processing this step because of errors.
NOTE: PROCEDURE NLMIXED used (Total process time):
      real time           0.03 seconds
      cpu time            0.01 seconds
PaigeMiller
Diamond | Level 26

I don't understand why you are getting this error, when similar statements work. I would probably report this to SAS Technical Support as a possible bug and see if they can explain it.

 

Sure, I figured that was the relevant part, here's the full log:

 

This is a good example of why we need the entire log. Just providing the error message is not of any use if we don't know where in the code the ERROR appears, plus there may be additional notes and warnings at the end that are helpful; and so the entire log for a PROC is always required, always, every single time.

--
Paige Miller
FreelanceReinh
Jade | Level 19

Hello @pblls,

 

I think nothing is wrong with the syntax and the fact that the compiler doesn't accept an expression followed by a plus or minus sign and a number (e.g. 0+0) in this place is just a bug. Thank you for notifying the community of the bug and the workarounds you've found (also inserting another plus sign seems to work: 0++0).

 

The most recent list of "Issues Addressed in SAS 9.4 (TS1M8)" is quite long and includes four items about PROC NLMIXED, but this new bug should be worth adding. So you may want to report it to SAS Technical Support.

pblls
Calcite | Level 5
Okay, thanks! I'll get in touch with them.

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
  • 5 replies
  • 409 views
  • 1 like
  • 3 in conversation