<?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: Incremental change to a value of macro variable in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Incremental-change-to-a-value-of-macro-variable/m-p/478433#M286346</link>
    <description>&lt;P&gt;Are you calling the macro variable K_COST or K_COST_M?&lt;/P&gt;</description>
    <pubDate>Mon, 16 Jul 2018 17:28:21 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2018-07-16T17:28:21Z</dc:date>
    <item>
      <title>Incremental change to a value of macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Incremental-change-to-a-value-of-macro-variable/m-p/478425#M286342</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;I am trying to change a value&amp;nbsp; for a macro variable decreasing it by 0.01 with each iteration and I cannot understand why this does not work. Could anyone tell me what is wrong in my code? Thank you!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%macro Low_cost_diet (K_cost_m=,&lt;BR /&gt; b=);&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt; %do i=1 %to &amp;amp;b.;&lt;/P&gt;
&lt;P&gt;%OptDietPattern (&lt;BR /&gt;DRIAG=16&lt;BR /&gt;,DRI=2&lt;BR /&gt;,DRIAG_Label='M - 2 TO 3 YRS' &lt;BR /&gt;,outputdata=OptimalDiet /*output data set*/&lt;BR /&gt;,Round=r15&lt;BR /&gt;,k_SOD=1&lt;BR /&gt;,k_IRON=1&lt;BR /&gt;,k_VitD=1&lt;BR /&gt;,k_CAL=1&lt;BR /&gt;,k_FI=1&lt;BR /&gt;,k_COST=&amp;amp;k_COST_m.&lt;BR /&gt;);&lt;/P&gt;
&lt;P&gt;%let k_COST=%eval(&amp;amp;k_COST-0.01);&lt;/P&gt;
&lt;P&gt;%end;&lt;/P&gt;
&lt;P&gt;%mend;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;%Low_cost_diet (K_cost_m=1,b=2);&lt;/P&gt;</description>
      <pubDate>Mon, 16 Jul 2018 17:18:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Incremental-change-to-a-value-of-macro-variable/m-p/478425#M286342</guid>
      <dc:creator>Lida</dc:creator>
      <dc:date>2018-07-16T17:18:00Z</dc:date>
    </item>
    <item>
      <title>Re: Incremental change to a value of macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Incremental-change-to-a-value-of-macro-variable/m-p/478427#M286343</link>
      <description>&lt;P&gt;%eval only performs integer arithmetic. You are trying to perform non-integer arithmetic using %eval.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You could use %sysevalf which will perform non-integer arithmetic.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 16 Jul 2018 17:19:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Incremental-change-to-a-value-of-macro-variable/m-p/478427#M286343</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2018-07-16T17:19:39Z</dc:date>
    </item>
    <item>
      <title>Re: Incremental change to a value of macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Incremental-change-to-a-value-of-macro-variable/m-p/478428#M286344</link>
      <description>&lt;P&gt;%EVAL() does not do floating point math.&lt;/P&gt;
&lt;P&gt;Either use %SYSEVALF() or parameterize the macro differently so that you are passing in an integer instead of a floating point value. Note it is very had to represent a floating point value exactly as a text string.&lt;/P&gt;</description>
      <pubDate>Mon, 16 Jul 2018 17:20:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Incremental-change-to-a-value-of-macro-variable/m-p/478428#M286344</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2018-07-16T17:20:27Z</dc:date>
    </item>
    <item>
      <title>Re: Incremental change to a value of macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Incremental-change-to-a-value-of-macro-variable/m-p/478431#M286345</link>
      <description>&lt;P&gt;thank you but it still does not work..&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;WARNING: Apparent symbolic reference K_COST not resolved.&lt;/P&gt;
&lt;P&gt;WARNING: Apparent symbolic reference K_COST not resolved.&lt;/P&gt;
&lt;P&gt;ERROR: A character operand was found in the %EVAL function or %IF condition where a numeric operand is required. The condition was:&lt;/P&gt;
&lt;P&gt;&amp;amp;k_COST-0.01&lt;/P&gt;
&lt;P&gt;ERROR: The macro LOW_COST_DIET will stop executing.&lt;/P&gt;
&lt;P&gt;&lt;LI-WRAPPER&gt;&lt;/LI-WRAPPER&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 16 Jul 2018 17:26:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Incremental-change-to-a-value-of-macro-variable/m-p/478431#M286345</guid>
      <dc:creator>Lida</dc:creator>
      <dc:date>2018-07-16T17:26:53Z</dc:date>
    </item>
    <item>
      <title>Re: Incremental change to a value of macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Incremental-change-to-a-value-of-macro-variable/m-p/478433#M286346</link>
      <description>&lt;P&gt;Are you calling the macro variable K_COST or K_COST_M?&lt;/P&gt;</description>
      <pubDate>Mon, 16 Jul 2018 17:28:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Incremental-change-to-a-value-of-macro-variable/m-p/478433#M286346</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2018-07-16T17:28:21Z</dc:date>
    </item>
    <item>
      <title>Re: Incremental change to a value of macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Incremental-change-to-a-value-of-macro-variable/m-p/478434#M286347</link>
      <description>&lt;P&gt;I suspect in the long run you might want to consider making your &lt;STRONG&gt;macro&lt;/STRONG&gt; variable integer and then doing a conversion in the step using&lt;/P&gt;
&lt;P&gt;,k_COST=&amp;amp;k_COST_m.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Or not incrementing the macro variable at all and using something like&lt;/P&gt;
&lt;P&gt;,k_COST=&amp;amp;k_COST_m - (0.01 * (&amp;amp;i - 1) )&lt;/P&gt;
&lt;P&gt;w&lt;/P&gt;</description>
      <pubDate>Mon, 16 Jul 2018 17:29:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Incremental-change-to-a-value-of-macro-variable/m-p/478434#M286347</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2018-07-16T17:29:36Z</dc:date>
    </item>
    <item>
      <title>Re: Incremental change to a value of macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Incremental-change-to-a-value-of-macro-variable/m-p/478437#M286348</link>
      <description>&lt;P&gt;I want to run %&lt;STRONG&gt;&lt;EM&gt;OptDietPattern macro starting with &lt;/EM&gt;&lt;/STRONG&gt;k_COST=1 and in the next iteration of that macro I want to decrease the cost by 0.01. I will add the data step for each iteration later ..now I just need to make reduction in cost work for each iteration.&lt;/P&gt;</description>
      <pubDate>Mon, 16 Jul 2018 17:33:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Incremental-change-to-a-value-of-macro-variable/m-p/478437#M286348</guid>
      <dc:creator>Lida</dc:creator>
      <dc:date>2018-07-16T17:33:05Z</dc:date>
    </item>
    <item>
      <title>Re: Incremental change to a value of macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Incremental-change-to-a-value-of-macro-variable/m-p/478441#M286349</link>
      <description>&lt;P&gt;The message is correct.&amp;nbsp; Your exterior macro %LOW_COST_DIET does not contain a macro variable named &amp;amp;K_COST.&amp;nbsp; Only the interior macro (%OptDietPattern) contains &amp;amp;K_COST.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I suspect you want to change this statement:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%let k_COST=%eval(&amp;amp;k_COST-0.01);&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Instead, use:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%let k_COST_m = %sysevalf (&amp;amp;k_COST_m - 0.01);&lt;/P&gt;</description>
      <pubDate>Mon, 16 Jul 2018 17:44:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Incremental-change-to-a-value-of-macro-variable/m-p/478441#M286349</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2018-07-16T17:44:01Z</dc:date>
    </item>
    <item>
      <title>Re: Incremental change to a value of macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Incremental-change-to-a-value-of-macro-variable/m-p/478445#M286350</link>
      <description>&lt;P&gt;Hurray.. it works… Thank you a lot&amp;nbsp; Astounding! Much appreciated! I spent the whole morning trying to make it work...You saved me another half of the day!&lt;/P&gt;
&lt;P&gt;Thank you very much!&lt;/P&gt;</description>
      <pubDate>Mon, 16 Jul 2018 17:48:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Incremental-change-to-a-value-of-macro-variable/m-p/478445#M286350</guid>
      <dc:creator>Lida</dc:creator>
      <dc:date>2018-07-16T17:48:22Z</dc:date>
    </item>
  </channel>
</rss>

