BookmarkSubscribeRSS Feed
Mike19
Fluorite | Level 6

 

 

Hi,

 

I get the following error message when calling the macro below: ERROR 22-322: Syntax error, expecting one of the following: *, /, =.

This message is related to is related to line 4278 (roptions). The macro executes when I remove the roptions parameter. In my regular Genmod model, the hospital variable is a numeric where hospital stay =1 and no hospital stay =0. My object is to compute the predicted probabilities and test whether the likelihood of a hospital stay differs based on whether one has Medicaid or not, by site.

 

For this macro, I referenced sample 38038: Predictive margins and average marginal effects (http://support.sas.com/kb/63/038.html)

 

Thank you for your help.

 

NOTE: The MARGINS macro used 0.42 seconds.

4274

4275 %Margins(data = test,

4276 class = medicaid site,

4277 response = hospital, 

4278 roptions = event = '1',

4279 model = medicaid site medicaid*site,

4280 dist = binomial,

4281 link = logit,

4282 geesubject = site, geecorr = exch,

4283 margins = medicaid,

4284 at = site,

4285 options = cl diff)

61 (&roptions)

-

22

61 (&roptions)

-

76

ERROR 22-322: Syntax error, expecting one of the following: *, /, =.

ERROR 76-322: Syntax error, statement will be ignored.

NOTE: The MARGINS macro used 0.58 seconds.

 

Edit by KB: fixed the link to the Knowledge Base.

4 REPLIES 4
andreas_lds
Jade | Level 19

@Mike19 wrote:

 

 

Hi,

 

I get the following error message when calling the macro below: ERROR 22-322: Syntax error, expecting one of the following: *, /, =.

This message is related to is related to line 4278 (roptions). The macro executes when I remove the roptions parameter. In my regular Genmod model, the hospital variable is a numeric where hospital stay =1 and no hospital stay =0. My object is to compute the predicted probabilities and test whether the likelihood of a hospital stay differs based on whether one has Medicaid or not, by site.

 

For this macro, I referenced sample 38038: Predictive margins and average marginal effects (http://support.sas.com/kb/63/038.html)

 

Thank you for your help.

 

NOTE: The MARGINS macro used 0.42 seconds.

4274

4275 %Margins(data = test,

4276 class = medicaid site,

4277 response = hospital, 

4278 roptions = event = '1',

4279 model = medicaid site medicaid*site,

4280 dist = binomial,

4281 link = logit,

4282 geesubject = site, geecorr = exch,

4283 margins = medicaid,

4284 at = site,

4285 options = cl diff)

61 (&roptions)

-

22

61 (&roptions)

-

76

ERROR 22-322: Syntax error, expecting one of the following: *, /, =.

ERROR 76-322: Syntax error, statement will be ignored.

NOTE: The MARGINS macro used 0.58 seconds.

 

Edit by KB: fixed the link to the Knowledge Base.


Please rerun with

options mprint;

So that the log contains more information.

ballardw
Super User

Set OPTIONS MPRINT; before running the macro. Then look at the log and or post the log here. Post LOG entries by copying from the log and pasting into a code box opened with the forum's {i} or "running man" icon to preserve formatting of text. 

Your log should include the entire proc call that uses this macro (since this is apprently to be called in the middle of one of the regression procs from context) so we can determine which options are likely to be valid

The specific error you post generally has undescore characters indicating where the error was observed (NOTE: not the cause, that can be missing characters in previous lines).

 

The option will show the text generated by the macro and the error message will appear in closer relation to that found error. The code box is important to keep the message window from moving the position of the underscore characters as the windows will "clean up" white space and remove indents and spaces that are needed to keep the error message aligned with the text.

 

Note that options in most cases appear after a / and we can't tell if any was used in the macro variable but one suspects that

options = cl diff)

61 (&roptions)

-

should be

options = cl diff /  (&roptions)

in your code.

s_lassen
Meteorite | Level 14

I looked at the macro, and the current version (http://support.sas.com/kb/63/addl/fusion_63038_16_margins.sas.txt) seems to have an error:

%if &roptions ne %then (%str(&roptions));

(line 924) which will resolve as follows with your code (which is equal to the examples given by SAS Institute): First the expression event = '1' is evaluated, a text comparison. This resolves to the numeric value 0 (false). Then that numeric value is compared to an empty string, comparing a number to a string gives an error.

 

You could change that line yourself in the downloaded macro, to something like

%if %length(&roptions) %then (%str(&roptions));

But I think you should raise the issue with SAS Institute, as this should be corrected by them.

Tom
Super User Tom
Super User

@s_lassen wrote:

I looked at the macro, and the current version (http://support.sas.com/kb/63/addl/fusion_63038_16_margins.sas.txt) seems to have an error:

%if &roptions ne %then (%str(&roptions));

(line 924) which will resolve as follows with your code (which is equal to the examples given by SAS Institute): First the expression event = '1' is evaluated, a text comparison. This resolves to the numeric value 0 (false). Then that numeric value is compared to an empty string, comparing a number to a string gives an error.

 

You could change that line yourself in the downloaded macro, to something like

%if %length(&roptions) %then (%str(&roptions));

But I think you should raise the issue with SAS Institute, as this should be corrected by them.


If that change to the code of the macro fixes the issue then the caller could add the macro quoting in the call to the macro and be able to get it to run without modifying the macro.

...roptions= %str(event = '1')...

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
  • 4 replies
  • 597 views
  • 0 likes
  • 5 in conversation