<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Macro to get additional estimates with proc nlmixed in Statistical Procedures</title>
    <link>https://communities.sas.com/t5/Statistical-Procedures/Macro-to-get-additional-estimates-with-proc-nlmixed/m-p/751675#M36563</link>
    <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/297250"&gt;@windy&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Try this modification of your %DO loop:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%do i=0 %to 3;
  estimate "beta&amp;amp;i"  (b2*b2 + b3*b3*&amp;amp;i)/(1 + b2*b2 + b3*b3*&amp;amp;i + c1*c1+c2*c2*&amp;amp;i);
  estimate "omega&amp;amp;i" (c1*c1 + c2*c2*&amp;amp;i)/(1 + b2*b2 + b3*b3*&amp;amp;i + c1*c1+c2*c2*&amp;amp;i);
%end;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Fri, 02 Jul 2021 10:07:45 GMT</pubDate>
    <dc:creator>FreelanceReinh</dc:creator>
    <dc:date>2021-07-02T10:07:45Z</dc:date>
    <item>
      <title>Macro to get additional estimates with proc nlmixed</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Macro-to-get-additional-estimates-with-proc-nlmixed/m-p/751628#M36562</link>
      <description>&lt;P&gt;Hello everyone,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am stuck in dealing with the macro to get the additional estimates using proc nlmixed.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Let's me generalize my model. My dependent variable is Y and independent variable is X1 and X2.&lt;/P&gt;&lt;P&gt;I also have a categorical variable Z as another independent variable. Z receive value 0, 1, 2, 3.&amp;nbsp;&lt;/P&gt;&lt;P&gt;My model looks like this:&lt;/P&gt;&lt;P&gt;%macro nlmixed(datain);&lt;/P&gt;&lt;P&gt;proc nlmixed data=&amp;amp;datain qpoints=15 ecov;&lt;BR /&gt;parms a0=-3 b1=0 b2=0 b3=0 c1=0 c2=0;&lt;BR /&gt;Y=a0 + b1*Z + b2*X1+ b3*X1*Z +c1*X2 + c2*X2*Z;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;/*I want to additionally estimate beta and omega based on the coefficients b2, b3, c1 and c2*/&lt;/P&gt;&lt;P&gt;/*for each value of Z, I have corresponding estimates for beta and omega*/&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;estimate 'beta0' (b2*b2 + b3*b3*&lt;FONT color="#FF0000"&gt;0&lt;/FONT&gt;)/(1 + b2*b2 + b3*b3*&lt;FONT color="#FF0000"&gt;0&lt;/FONT&gt; + c1*c1+c2*c2*&lt;FONT color="#FF0000"&gt;0&lt;/FONT&gt;);&lt;BR /&gt;estimate 'omega0' (c1*c1 + c2*c2*&lt;FONT color="#FF0000"&gt;0&lt;/FONT&gt;)/(1 + b2*b2 + b3*b3*&lt;FONT color="#FF0000"&gt;0&lt;/FONT&gt; + c1*c1+c2*c2*&lt;FONT color="#FF0000"&gt;0&lt;/FONT&gt;);&lt;BR /&gt;estimate 'beta1' (b2*b2 + b3*b3*&lt;FONT color="#FF0000"&gt;1&lt;/FONT&gt;)/(1 + b2*b2 + b3*b3*&lt;FONT color="#FF0000"&gt;1&lt;/FONT&gt; + c1*c1+c2*c2*&lt;FONT color="#FF0000"&gt;1&lt;/FONT&gt;);&lt;BR /&gt;estimate 'omega1' (c1*c1 + c2*c2*&lt;FONT color="#FF0000"&gt;1&lt;/FONT&gt;)/(1 + b2*b2 + b3*b3*&lt;FONT color="#FF0000"&gt;1&lt;/FONT&gt; + c1*c1+c2*c2*&lt;FONT color="#FF0000"&gt;1&lt;/FONT&gt;);&lt;/P&gt;&lt;P&gt;estimate 'beta2' (b2*b2 + b3*b3*&lt;FONT color="#FF0000"&gt;2&lt;/FONT&gt;)/(1 + b2*b2 + b3*b3*&lt;FONT color="#FF0000"&gt;2&lt;/FONT&gt; + c1*c1+c2*c2*&lt;FONT color="#FF0000"&gt;2&lt;/FONT&gt;);&lt;BR /&gt;estimate 'omega2' (c1*c1 + c2*c2*&lt;FONT color="#FF0000"&gt;2&lt;/FONT&gt;)/(1 + b2*b2 + b3*b3*&lt;FONT color="#FF0000"&gt;2&lt;/FONT&gt; + c1*c1+c2*c2*&lt;FONT color="#FF0000"&gt;2&lt;/FONT&gt;);&lt;/P&gt;&lt;P&gt;estimate 'beta3' (b2*b2 + b3*b3*&lt;FONT color="#FF0000"&gt;3&lt;/FONT&gt;)/(1 + b2*b2 + b3*b3*&lt;FONT color="#FF0000"&gt;3&lt;/FONT&gt; + c1*c1+c2*c2*&lt;FONT color="#FF0000"&gt;3&lt;/FONT&gt;);&lt;BR /&gt;estimate 'omega3' (c1*c1 + c2*c2*&lt;FONT color="#FF0000"&gt;3&lt;/FONT&gt;)/(1 + b2*b2 + b3*b3*&lt;FONT color="#FF0000"&gt;3&lt;/FONT&gt; + c1*c1+c2*c2*&lt;FONT color="#FF0000"&gt;3&lt;/FONT&gt;);&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;%mend;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The macro works, but the problem is I have the other variable Z where it has up to 10 values. It means that I have to write 20 estimate statements. So, I was trying to plug a do-loop in the macro, but it's not working &lt;span class="lia-unicode-emoji" title=":disappointed_face:"&gt;😞&lt;/span&gt; The do-loop I have tried is:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%do i = 0 to 3;&amp;nbsp;&lt;/P&gt;&lt;P&gt;estimate 'beta&amp;amp;i' %eval((b2*b2 + b3*b3*&lt;FONT color="#ff0000"&gt;&amp;amp;i&lt;/FONT&gt;)/(1 + b2*b2 + b3*b3*&lt;FONT color="#FF0000"&gt;&amp;amp;i&lt;/FONT&gt; + c1*c1+c2*c2*&lt;FONT color="#FF0000"&gt;&amp;amp;i&lt;/FONT&gt;));&lt;BR /&gt;estimate 'omega&amp;amp;i' %eval((c1*c1 + c2*c2*&lt;FONT color="#FF0000"&gt;&amp;amp;i&lt;/FONT&gt;)/(1 + b2*b2 + b3*b3*&lt;FONT color="#FF0000"&gt;&amp;amp;i&lt;/FONT&gt; + c1*c1+c2*c2*&lt;FONT color="#FF0000"&gt;&amp;amp;i&lt;/FONT&gt;));&lt;/P&gt;&lt;P&gt;%end;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Could you please help me to fix the do-loop so that I can save time in fixing code and running it with different variable Z?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you so much in advance.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards,&amp;nbsp;&lt;/P&gt;&lt;P&gt;Windy.&lt;/P&gt;</description>
      <pubDate>Fri, 02 Jul 2021 06:51:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Macro-to-get-additional-estimates-with-proc-nlmixed/m-p/751628#M36562</guid>
      <dc:creator>windy</dc:creator>
      <dc:date>2021-07-02T06:51:39Z</dc:date>
    </item>
    <item>
      <title>Re: Macro to get additional estimates with proc nlmixed</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Macro-to-get-additional-estimates-with-proc-nlmixed/m-p/751675#M36563</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/297250"&gt;@windy&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Try this modification of your %DO loop:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%do i=0 %to 3;
  estimate "beta&amp;amp;i"  (b2*b2 + b3*b3*&amp;amp;i)/(1 + b2*b2 + b3*b3*&amp;amp;i + c1*c1+c2*c2*&amp;amp;i);
  estimate "omega&amp;amp;i" (c1*c1 + c2*c2*&amp;amp;i)/(1 + b2*b2 + b3*b3*&amp;amp;i + c1*c1+c2*c2*&amp;amp;i);
%end;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 02 Jul 2021 10:07:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Macro-to-get-additional-estimates-with-proc-nlmixed/m-p/751675#M36563</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2021-07-02T10:07:45Z</dc:date>
    </item>
    <item>
      <title>Re: Macro to get additional estimates with proc nlmixed</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Macro-to-get-additional-estimates-with-proc-nlmixed/m-p/751706#M36564</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/32733"&gt;@FreelanceReinh&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The calculation is working, but the &amp;amp;i in estimation parameters (beta&amp;amp;i and omega&amp;amp;i) are not resolved.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 02 Jul 2021 12:03:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Macro-to-get-additional-estimates-with-proc-nlmixed/m-p/751706#M36564</guid>
      <dc:creator>windy</dc:creator>
      <dc:date>2021-07-02T12:03:27Z</dc:date>
    </item>
    <item>
      <title>Re: Macro to get additional estimates with proc nlmixed</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Macro-to-get-additional-estimates-with-proc-nlmixed/m-p/751722#M36565</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/297250"&gt;@windy&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/32733"&gt;@FreelanceReinh&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The calculation is working, but the &amp;amp;i in estimation parameters (beta&amp;amp;i and omega&amp;amp;i) are not resolved.&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;When you submit&lt;/P&gt;
&lt;PRE&gt;options mprint;&lt;/PRE&gt;
&lt;P&gt;and then the macro call, the resolved code should occur in the log, as shown below:&lt;/P&gt;
&lt;PRE&gt;...
MPRINT(NLMIXED):   estimate "beta0" (b2*b2 + b3*b3*0)/(1 + b2*b2 + b3*b3*0 + c1*c1+c2*c2*0);
MPRINT(NLMIXED):   estimate "omega0" (c1*c1 + c2*c2*0)/(1 + b2*b2 + b3*b3*0 + c1*c1+c2*c2*0);
MPRINT(NLMIXED):   estimate "beta1" (b2*b2 + b3*b3*1)/(1 + b2*b2 + b3*b3*1 + c1*c1+c2*c2*1);
MPRINT(NLMIXED):   estimate "omega1" (c1*c1 + c2*c2*1)/(1 + b2*b2 + b3*b3*1 + c1*c1+c2*c2*1);
MPRINT(NLMIXED):   estimate "beta2" (b2*b2 + b3*b3*2)/(1 + b2*b2 + b3*b3*2 + c1*c1+c2*c2*2);
MPRINT(NLMIXED):   estimate "omega2" (c1*c1 + c2*c2*2)/(1 + b2*b2 + b3*b3*2 + c1*c1+c2*c2*2);
MPRINT(NLMIXED):   estimate "beta3" (b2*b2 + b3*b3*3)/(1 + b2*b2 + b3*b3*3 + c1*c1+c2*c2*3);
MPRINT(NLMIXED):   estimate "omega3" (c1*c1 + c2*c2*3)/(1 + b2*b2 + b3*b3*3 + c1*c1+c2*c2*3);
...&lt;/PRE&gt;
&lt;P&gt;Note that I used double quotes around "beta&amp;amp;i" and "omega&amp;amp;i", whereas the single quotes in your code prevented the resolution of the macro variable reference &amp;amp;i.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 02 Jul 2021 13:02:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Macro-to-get-additional-estimates-with-proc-nlmixed/m-p/751722#M36565</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2021-07-02T13:02:21Z</dc:date>
    </item>
    <item>
      <title>Re: Macro to get additional estimates with proc nlmixed</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Macro-to-get-additional-estimates-with-proc-nlmixed/m-p/751736#M36566</link>
      <description>&lt;P&gt;Oh wow, beautiful. It's working now.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you so much for your help,&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/32733"&gt;@FreelanceReinh&lt;/a&gt;.&lt;/P&gt;</description>
      <pubDate>Fri, 02 Jul 2021 13:44:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Macro-to-get-additional-estimates-with-proc-nlmixed/m-p/751736#M36566</guid>
      <dc:creator>windy</dc:creator>
      <dc:date>2021-07-02T13:44:27Z</dc:date>
    </item>
  </channel>
</rss>

