BookmarkSubscribeRSS Feed
Calcite | Level 5



I am working through an example given by SAS to create relative risk from this example:


I'm working through it but I am now stuck. I run the preceding code:


data question;
        input Gender $ Response $ Count;
      Women Yes 45
      Women  No 55
      Men   Yes 30
      Men    No 70

proc freq data=question order=data;
        weight Count;
        tables Gender*Response / relrisk;

      proc logistic data=question;
        freq count;
        class gender(ref="Men") / param=glm;
        model response(event="Yes")=gender;
        lsmeans gender / e ilink;
        ods output coef=coeffs;
        store out=ques;


So far, so good. HOWEVER, when I submit the suggested %NLMeans macro:


 %NLMeans(instore=ques, coef=coeffs, link=logit, options=ratio, title=Relative Risk);


I receive the following message:


"Warning: Apparent Invocation NLMeans not resolved"


Please advise! Thank you in advance!







Jade | Level 19

Hi @davidmaron,


You need to download and submit the macro code from in order to make it available to your SAS session.

Obsidian | Level 7

Hello, where do I start downloading the code? I started with "Macro Argument List Start" and copied the following code. However, I cannot display the results after using NLmeans. Could you please give me the specific process of using NLmeans? Since I am an initial scholar, I do not know how to use macros for the time being. Thank you very much.

Jade | Level 19

Hello @Lucai_sister,


  1. First of all, make sure to use the latest version of the NLMeans macro:
    Under the "Downloads" tab on the page Sample 62362: Estimate and test differences, ratios, or contrasts of means in generalized linear mod... you find the current link, which is different from that provided in my reply from 2019 in this thread. Download the text file and save it as in a directory that your SAS session can access.

  2. Do the same for the NLEst macro, which is a prerequisite for the NLMeans macro:
    You find a link to the latest version of it under the "Downloads" tab on the page Sample 58775: Estimating nonlinear combinations of model parameters. Download the text file and save it as in the same directory as above.

  3. In your SAS session submit two %INCLUDE statements:
    %include 'your\path\';
    %include 'your\path\';
    (of course, with "your\path" replaced by the location you chose for the two .sas files).

  4. Use the code provided in a SAS Usage Note such as Usage Note 57798: Estimating relative risks in a multinomial response model to test the NLMeans macro. In this example you would submit
    - the DATA step creating the SCHOOL dataset,
    - the PROC LOGISTIC step creating the COEFFS dataset and the LOGMOD model item store
    - and finally the %NLMeans(...) macro call. 

    As a result you should obtain the table "School RRs on each Style" as displayed in the Usage Note. It appears that the latest version of creates an additional column "Null Value" in that table, but the values in the other columns (Estimate, Standard Error, etc.) match the numbers from the Usage Note (in spite of the warning about the final Hessian matrix in the log).

  5. Then you are ready to apply the NLMeans macro to your own data. Good luck! If you encounter problems in this Step 5, please start a new topic in the Statistical Procedures forum.


Hint: Generally, it is much better to open a new thread than to add questions to an old one (like from 2019), which only a few people will read.



Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.

If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website. 

Register now!

From SAS Users blog
Want more? Visit our blog for more articles like these.
5 Steps to Your First Analytics Project Using SAS

For SAS newbies, this video is a great way to get started. James Harroun walks through the process using SAS Studio for SAS OnDemand for Academics, but the same steps apply to any analytics project.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 3 replies
  • 3 in conversation