<?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: Find min for a list of variables in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Find-min-for-a-list-of-variables/m-p/796499#M255598</link>
    <description>&lt;P&gt;If the methods already proposed can work depends on the real names of your variables.&lt;/P&gt;
&lt;P&gt;If you have such nicely numbered names, then the "of v2-v5" will work. But if you have names like a b c d e f (no numeric suffix, or no complete sequence), you will need the "of b--f" construct, but this depends on the &lt;EM&gt;physical sequence of variables&lt;/EM&gt; within an observation, and that can change in numerous ways without you even noticing it (no WARNING, ERROR or NOTE in the log).&lt;/P&gt;
&lt;P&gt;For the latter, I would go with a preceding step that extracts the necessary names from DICTIONARY.COLUMNS into a macro variable for use in the MIN function.&lt;/P&gt;</description>
    <pubDate>Wed, 16 Feb 2022 09:40:03 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2022-02-16T09:40:03Z</dc:date>
    <item>
      <title>Find min for a list of variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Find-min-for-a-list-of-variables/m-p/796450#M255577</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;I want to find record that: v1&amp;lt; min (v2,v3,v4.... vn).&lt;/P&gt;
&lt;P&gt;Is there way rather than listing all v?&lt;/P&gt;
&lt;P&gt;Thanks&amp;nbsp;&lt;/P&gt;
&lt;P&gt;HHC&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data a; 
input id v1 v2 v3 v4 v5;
datalines;
1 4 5 6 7 8
2 5 9 10 85 3
3 99 1 2 3 4
;run;

data b; set a;
if v1&amp;lt; min(v2-v5); *SAS take it as minus;
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 16 Feb 2022 04:29:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Find-min-for-a-list-of-variables/m-p/796450#M255577</guid>
      <dc:creator>hhchenfx</dc:creator>
      <dc:date>2022-02-16T04:29:29Z</dc:date>
    </item>
    <item>
      <title>Re: Find min for a list of variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Find-min-for-a-list-of-variables/m-p/796453#M255578</link>
      <description>&lt;P&gt;Define an array containing V2-V5 (using &lt;EM&gt;&lt;STRONG&gt;v2-v5&lt;/STRONG&gt;&lt;/EM&gt; expession), then find the minimum of that array, using the &lt;EM&gt;&lt;STRONG&gt;of arrayname{*}&lt;/STRONG&gt;&lt;/EM&gt; expression:&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data a; 
input id v1 v2 v3 v4 v5;
datalines;
1 4 5 6 7 8
2 5 9 10 85 3
3 99 1 2 3 4
;run;

data b; set a;
  array _v2_thru_5 {*} v2-v5;
  if v1&amp;lt; min(of _v2_thru_5{*}); 
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 16 Feb 2022 04:57:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Find-min-for-a-list-of-variables/m-p/796453#M255578</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2022-02-16T04:57:14Z</dc:date>
    </item>
    <item>
      <title>Re: Find min for a list of variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Find-min-for-a-list-of-variables/m-p/796487#M255594</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/49486"&gt;@hhchenfx&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For a&amp;nbsp;&lt;EM&gt;numbered range list&lt;/EM&gt; or a&amp;nbsp;&lt;EM&gt;name range list&lt;/EM&gt; (see documentation of &lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/lepg/p08ywlo51p6ezbn1lde9f0aphq6r.htm" target="_blank" rel="noopener"&gt;SAS Variable Lists&lt;/A&gt;) you can use the OF operator without an array. Both of these are applicable to your example:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Numbered range list:&lt;/P&gt;
&lt;PRE&gt;if v1 &amp;lt; min(&lt;STRONG&gt;of&lt;/STRONG&gt; v2-v5);&lt;/PRE&gt;
&lt;P&gt;Name range list:&lt;/P&gt;
&lt;PRE&gt;if v1 &amp;lt; min(&lt;STRONG&gt;of&lt;/STRONG&gt; v2--v5);&lt;/PRE&gt;
&lt;P&gt;The OF operator signals that the hyphens between "&lt;FONT face="courier new,courier"&gt;v2&lt;/FONT&gt;" and "&lt;FONT face="courier new,courier"&gt;v5&lt;/FONT&gt;" are not minus signs.&lt;/P&gt;</description>
      <pubDate>Wed, 16 Feb 2022 08:57:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Find-min-for-a-list-of-variables/m-p/796487#M255594</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2022-02-16T08:57:37Z</dc:date>
    </item>
    <item>
      <title>Re: Find min for a list of variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Find-min-for-a-list-of-variables/m-p/796499#M255598</link>
      <description>&lt;P&gt;If the methods already proposed can work depends on the real names of your variables.&lt;/P&gt;
&lt;P&gt;If you have such nicely numbered names, then the "of v2-v5" will work. But if you have names like a b c d e f (no numeric suffix, or no complete sequence), you will need the "of b--f" construct, but this depends on the &lt;EM&gt;physical sequence of variables&lt;/EM&gt; within an observation, and that can change in numerous ways without you even noticing it (no WARNING, ERROR or NOTE in the log).&lt;/P&gt;
&lt;P&gt;For the latter, I would go with a preceding step that extracts the necessary names from DICTIONARY.COLUMNS into a macro variable for use in the MIN function.&lt;/P&gt;</description>
      <pubDate>Wed, 16 Feb 2022 09:40:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Find-min-for-a-list-of-variables/m-p/796499#M255598</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2022-02-16T09:40:03Z</dc:date>
    </item>
  </channel>
</rss>

