<?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 How to find dynamic minimun value with macro? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-find-dynamic-minimun-value-with-macro/m-p/773476#M245724</link>
    <description>&lt;P&gt;I need find dynamic minimum value depend on _n_ , some like below,&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="yj111_0-1633984488858.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/64587iC9AB26DDB9D887C1/image-size/medium?v=v2&amp;amp;px=400" role="button" title="yj111_0-1633984488858.png" alt="yj111_0-1633984488858.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Column K is the field I want, but the min range is changed by N. I did have some marco set up but it did not work since it did not take _N_ as numeric&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;%LET T=_N_;&lt;BR /&gt;want =MIN(OF X(&amp;amp;T)-X(&amp;amp;T+3));&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;anyone can help?&amp;nbsp; many Appreciate here!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 11 Oct 2021 20:40:57 GMT</pubDate>
    <dc:creator>yj111</dc:creator>
    <dc:date>2021-10-11T20:40:57Z</dc:date>
    <item>
      <title>How to find dynamic minimun value with macro?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-find-dynamic-minimun-value-with-macro/m-p/773476#M245724</link>
      <description>&lt;P&gt;I need find dynamic minimum value depend on _n_ , some like below,&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="yj111_0-1633984488858.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/64587iC9AB26DDB9D887C1/image-size/medium?v=v2&amp;amp;px=400" role="button" title="yj111_0-1633984488858.png" alt="yj111_0-1633984488858.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Column K is the field I want, but the min range is changed by N. I did have some marco set up but it did not work since it did not take _N_ as numeric&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;%LET T=_N_;&lt;BR /&gt;want =MIN(OF X(&amp;amp;T)-X(&amp;amp;T+3));&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;anyone can help?&amp;nbsp; many Appreciate here!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 11 Oct 2021 20:40:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-find-dynamic-minimun-value-with-macro/m-p/773476#M245724</guid>
      <dc:creator>yj111</dc:creator>
      <dc:date>2021-10-11T20:40:57Z</dc:date>
    </item>
    <item>
      <title>Re: How to find dynamic minimun value with macro?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-find-dynamic-minimun-value-with-macro/m-p/773484#M245728</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/402465"&gt;@yj111&lt;/a&gt;&amp;nbsp;and welcome to the SAS Support Communities!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Do you have only six variables x1-x6 and six observations?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Then use an array, no macro variables needed:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
set have;
array a[8] x1-x6 x6 x6;
if n(a[_n_],a[_n_+1],a[_n_+2]) then m=min(a[_n_],a[_n_+1],a[_n_+2]);
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If you don't have missing values, you can omit the IF condition.&lt;/P&gt;</description>
      <pubDate>Mon, 11 Oct 2021 21:07:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-find-dynamic-minimun-value-with-macro/m-p/773484#M245728</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2021-10-11T21:07:18Z</dc:date>
    </item>
    <item>
      <title>Re: How to find dynamic minimun value with macro?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-find-dynamic-minimun-value-with-macro/m-p/773485#M245729</link>
      <description>&lt;P&gt;No macros needed, nor would they be a good idea here. This is a place where an ARRAY works perfectly.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
    set have;
    array x x1-x6;
    if _n_&amp;gt;1 and _n_&amp;lt;6 then min_for_row=min(x(_n_+1),x(_n_));
    else if _n_=1 then min_for_row=min(of x1-x3);
    else if _n_=6 then min_for_row=x6;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 11 Oct 2021 21:19:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-find-dynamic-minimun-value-with-macro/m-p/773485#M245729</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2021-10-11T21:19:20Z</dc:date>
    </item>
    <item>
      <title>Re: How to find dynamic minimun value with macro?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-find-dynamic-minimun-value-with-macro/m-p/773495#M245733</link>
      <description>&lt;P&gt;It works perfectly!!&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you!&lt;/P&gt;</description>
      <pubDate>Mon, 11 Oct 2021 21:28:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-find-dynamic-minimun-value-with-macro/m-p/773495#M245733</guid>
      <dc:creator>yj111</dc:creator>
      <dc:date>2021-10-11T21:28:12Z</dc:date>
    </item>
    <item>
      <title>Re: How to find dynamic minimun value with macro?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-find-dynamic-minimun-value-with-macro/m-p/773496#M245734</link>
      <description>&lt;P&gt;Hello &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/402465"&gt;@yj111&lt;/a&gt; , you need to mark the reply from &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/32733"&gt;@FreelanceReinh&lt;/a&gt; as correct and not your reply that says it works perfectly as the correct answer.&lt;/P&gt;</description>
      <pubDate>Mon, 11 Oct 2021 21:32:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-find-dynamic-minimun-value-with-macro/m-p/773496#M245734</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2021-10-11T21:32:54Z</dc:date>
    </item>
    <item>
      <title>Re: How to find dynamic minimun value with macro?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-find-dynamic-minimun-value-with-macro/m-p/773501#M245736</link>
      <description>thank you Paige!&lt;BR /&gt;small changes I made from your suggestion:&lt;BR /&gt;&lt;BR /&gt;data want;&lt;BR /&gt;set have;&lt;BR /&gt;&lt;BR /&gt;array X X1-X6;&lt;BR /&gt;if _n_&amp;gt;=1 and _n_&amp;lt;5 then min_for_row=min(X(_n_+1),X(_n_),X(_n_+2));&lt;BR /&gt;&lt;BR /&gt;else if _n_=5 then min_for_row=min(X(_N_-1),X(_N_));&lt;BR /&gt;ELSE IF _N_=6 THEN MIN_FOR_ROW=X(_N_);&lt;BR /&gt;&lt;BR /&gt;run;&lt;BR /&gt;</description>
      <pubDate>Mon, 11 Oct 2021 21:49:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-find-dynamic-minimun-value-with-macro/m-p/773501#M245736</guid>
      <dc:creator>yj111</dc:creator>
      <dc:date>2021-10-11T21:49:30Z</dc:date>
    </item>
    <item>
      <title>Re: How to find dynamic minimun value with macro?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-find-dynamic-minimun-value-with-macro/m-p/773596#M245778</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/402465"&gt;@yj111&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;thank you Paige!&lt;BR /&gt;&lt;BR /&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Repeating my earlier request:&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;"Hello&amp;nbsp;&lt;/SPAN&gt;&lt;A href="https://communities.sas.com/t5/user/viewprofilepage/user-id/402465" target="_blank"&gt;@yj111&lt;/A&gt;&lt;SPAN&gt;&amp;nbsp;, you need to mark the reply from&amp;nbsp;&lt;/SPAN&gt;&lt;A href="https://communities.sas.com/t5/user/viewprofilepage/user-id/32733" target="_blank"&gt;@FreelanceReinhard&lt;/A&gt;&lt;SPAN&gt;&amp;nbsp;as correct and not your reply that says it works perfectly as the correct answer."&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 12 Oct 2021 12:00:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-find-dynamic-minimun-value-with-macro/m-p/773596#M245778</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2021-10-12T12:00:08Z</dc:date>
    </item>
  </channel>
</rss>

