<?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 lowest value in multple columns in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/find-lowest-value-in-multple-columns/m-p/534871#M146826</link>
    <description>&lt;P&gt;An easy-to-understand approach:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;final = v3;&lt;/P&gt;
&lt;P&gt;if final = " " then final = v2;&lt;/P&gt;
&lt;P&gt;if final = " " then final = v1;&lt;/P&gt;</description>
    <pubDate>Tue, 12 Feb 2019 15:18:15 GMT</pubDate>
    <dc:creator>Astounding</dc:creator>
    <dc:date>2019-02-12T15:18:15Z</dc:date>
    <item>
      <title>find lowest value in multple columns</title>
      <link>https://communities.sas.com/t5/SAS-Programming/find-lowest-value-in-multple-columns/m-p/534833#M146810</link>
      <description>&lt;P&gt;Hi All,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have 3 values corresponsing to each ID.&lt;/P&gt;&lt;P&gt;I am looking for output as lowest V column corresponding ID.&lt;/P&gt;&lt;P&gt;In the output of Final column, Value should be picked always on V3 , V2, V1 sequence priority.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If all three is not null then V3&lt;/P&gt;&lt;P&gt;if V1 and V2 is not null &amp;nbsp;and V3 is nullthen V2&lt;/P&gt;&lt;P&gt;if v2 and v3 is null and V1 is not null then v1&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;note : ID is duplicated in rows.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Source :&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
infile datalines dlm=' ' dsd;
input id $ V1 $ V2 $ V3 $;
datalines;
1 x y z
2 x y
3 x
1 x y
3 x y z
;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;expecting output :&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;ID Final&lt;/P&gt;&lt;P&gt;1 &amp;nbsp; &amp;nbsp;z&lt;/P&gt;&lt;P&gt;2 &amp;nbsp; &amp;nbsp;y&lt;/P&gt;&lt;P&gt;3 &amp;nbsp; &amp;nbsp;x&lt;/P&gt;&lt;P&gt;1 &amp;nbsp; &amp;nbsp;y&lt;/P&gt;&lt;P&gt;3 &amp;nbsp; &amp;nbsp;z&lt;/P&gt;</description>
      <pubDate>Tue, 12 Feb 2019 13:47:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/find-lowest-value-in-multple-columns/m-p/534833#M146810</guid>
      <dc:creator>Riteshdell</dc:creator>
      <dc:date>2019-02-12T13:47:17Z</dc:date>
    </item>
    <item>
      <title>Re: find lowest value in multple columns</title>
      <link>https://communities.sas.com/t5/SAS-Programming/find-lowest-value-in-multple-columns/m-p/534838#M146812</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/6813"&gt;@Riteshdell&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hi All,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have 3 values corresponsing to each ID.&lt;/P&gt;
&lt;P&gt;I am looking for output as lowest V column corresponding ID.&lt;/P&gt;
&lt;P&gt;In the output of Final column, Value should be picked always on V3 , V2, V1 sequence priority.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If all three is not null then V3&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if not missing(v1) and not missing(v2) and not missing(v3) then output=v3;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;if V1 and V2 is not null &amp;nbsp;and V3 is nullthen V2&lt;/P&gt;
&lt;P&gt;if v2 and v3 is null and V1 is not null then v1&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;These are obvious modifications of the code above.&lt;/P&gt;</description>
      <pubDate>Tue, 12 Feb 2019 13:51:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/find-lowest-value-in-multple-columns/m-p/534838#M146812</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2019-02-12T13:51:01Z</dc:date>
    </item>
    <item>
      <title>Re: find lowest value in multple columns</title>
      <link>https://communities.sas.com/t5/SAS-Programming/find-lowest-value-in-multple-columns/m-p/534871#M146826</link>
      <description>&lt;P&gt;An easy-to-understand approach:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;final = v3;&lt;/P&gt;
&lt;P&gt;if final = " " then final = v2;&lt;/P&gt;
&lt;P&gt;if final = " " then final = v1;&lt;/P&gt;</description>
      <pubDate>Tue, 12 Feb 2019 15:18:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/find-lowest-value-in-multple-columns/m-p/534871#M146826</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2019-02-12T15:18:15Z</dc:date>
    </item>
    <item>
      <title>Re: find lowest value in multple columns</title>
      <link>https://communities.sas.com/t5/SAS-Programming/find-lowest-value-in-multple-columns/m-p/534880#M146830</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Another solution using an array and&amp;nbsp;coalescec function to retrieve the first non missing element :&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
	infile datalines dlm=' ' dsd;
	input id $ V1 $ V2 $ V3 $;
	length final $1.;
	array v(*) v3-v1;
	final=coalescec(of v(*));
	datalines;
1 x y z
2 x y
3 x
1 x y
3 x y z
;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 12 Feb 2019 15:42:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/find-lowest-value-in-multple-columns/m-p/534880#M146830</guid>
      <dc:creator>gamotte</dc:creator>
      <dc:date>2019-02-12T15:42:52Z</dc:date>
    </item>
  </channel>
</rss>

