<?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: Return min date from multiple columns that is not zero in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Return-min-date-from-multiple-columns-that-is-not-zero/m-p/199228#M49792</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I am still not sure how to use the array to create a forth column with the min date, can you please elaborate?&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 18 Apr 2015 09:04:19 GMT</pubDate>
    <dc:creator>ammarhm</dc:creator>
    <dc:date>2015-04-18T09:04:19Z</dc:date>
    <item>
      <title>Return min date from multiple columns that is not zero</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Return-min-date-from-multiple-columns-that-is-not-zero/m-p/199225#M49789</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;Imagine we have the following SAS table:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;TABLE border="1" class="jiveBorder" height="130" style="border: 1px solid #000000; width: 362px; height: 132px;" width="360"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TH style="text-align: center; background-color: #6690bc; color: #ffffff; padding: 2px;" valign="middle"&gt;Treatment&lt;/TH&gt;&lt;TH style="text-align: center; background-color: #6690bc; color: #ffffff; padding: 2px;" valign="middle"&gt;Date1&lt;/TH&gt;&lt;TH style="text-align: center; background-color: #6690bc; color: #ffffff; padding: 2px;" valign="middle"&gt;Date2&lt;/TH&gt;&lt;TH style="text-align: center; background-color: #6690bc; color: #ffffff; padding: 2px;" valign="middle"&gt;Date3&lt;/TH&gt;&lt;TH style="text-align: center; background-color: #6690bc; color: #ffffff; padding: 2px;" valign="middle"&gt;&lt;STRONG&gt;Effect&lt;/STRONG&gt;&lt;/TH&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;1&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;12/03/2002&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;&lt;SPAN style="font-size: 13.3333330154419px;"&gt;02/02/2012&lt;/SPAN&gt;&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;0&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;3&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;2&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;&lt;SPAN style="font-size: 13.3333330154419px;"&gt;01/11/2009&lt;/SPAN&gt;&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;&lt;SPAN style="font-size: 13.3333330154419px;"&gt;2/10/2011&lt;/SPAN&gt;&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;0&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;2&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;2&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;&lt;SPAN style="font-size: 13.3333330154419px;"&gt;21/08/2013&lt;/SPAN&gt;&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;&lt;SPAN style="font-size: 13.3333330154419px;"&gt;29/03/2012&lt;/SPAN&gt;&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;&lt;SPAN style="font-size: 13.3333330154419px;"&gt;2/10/2012&lt;/SPAN&gt;&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;1&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;&lt;SPAN style="font-size: 13.3333330154419px;"&gt;11/10/2015&lt;/SPAN&gt;&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;0&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;&lt;SPAN style="font-size: 13.3333330154419px;"&gt;26/12/2014&lt;/SPAN&gt;&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;3&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am trying to get the "earliest" date in each row that is not equal to zero&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;the following code will not woke because the empty cells are coded as 0 &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc sql;&lt;/P&gt;&lt;P&gt;create table want as&lt;/P&gt;&lt;P&gt;select&lt;/P&gt;&lt;P&gt;min (Date1, Date2, Date3) as min_date&lt;/P&gt;&lt;P&gt;from have;&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any ideas on how to do that (without replacing all zeros with missing values)?&lt;/P&gt;&lt;P&gt;best regards&lt;/P&gt;&lt;P&gt;Am&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 18 Apr 2015 08:00:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Return-min-date-from-multiple-columns-that-is-not-zero/m-p/199225#M49789</guid>
      <dc:creator>ammarhm</dc:creator>
      <dc:date>2015-04-18T08:00:38Z</dc:date>
    </item>
    <item>
      <title>Re: Return min date from multiple columns that is not zero</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Return-min-date-from-multiple-columns-that-is-not-zero/m-p/199226#M49790</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I am a little curious that how can you get 0 if they are all date variables . Which format are you using to these variables.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;min=999999;&lt;/P&gt;&lt;P&gt;array x{*} date: ;&lt;/P&gt;&lt;P&gt;do i=1 to dim(x);&lt;/P&gt;&lt;P&gt;if x{i} lt min&amp;nbsp; and x{i} ne 0 then min=x{i};&lt;/P&gt;&lt;P&gt;end;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 18 Apr 2015 08:25:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Return-min-date-from-multiple-columns-that-is-not-zero/m-p/199226#M49790</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2015-04-18T08:25:19Z</dc:date>
    </item>
    <item>
      <title>Re: Return min date from multiple columns that is not zero</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Return-min-date-from-multiple-columns-that-is-not-zero/m-p/199227#M49791</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Xia&lt;/P&gt;&lt;P&gt;Point well take, that was actually the excel file, when importing to SAS it is converting to number of days after 1 jan 1960.&lt;/P&gt;&lt;P&gt;I am not very familiar with SAS arrays, I guess I will have to read a bit on the subject, &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 18 Apr 2015 08:32:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Return-min-date-from-multiple-columns-that-is-not-zero/m-p/199227#M49791</guid>
      <dc:creator>ammarhm</dc:creator>
      <dc:date>2015-04-18T08:32:49Z</dc:date>
    </item>
    <item>
      <title>Re: Return min date from multiple columns that is not zero</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Return-min-date-from-multiple-columns-that-is-not-zero/m-p/199228#M49792</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I am still not sure how to use the array to create a forth column with the min date, can you please elaborate?&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 18 Apr 2015 09:04:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Return-min-date-from-multiple-columns-that-is-not-zero/m-p/199228#M49792</guid>
      <dc:creator>ammarhm</dc:creator>
      <dc:date>2015-04-18T09:04:19Z</dc:date>
    </item>
    <item>
      <title>Re: Return min date from multiple columns that is not zero</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Return-min-date-from-multiple-columns-that-is-not-zero/m-p/199229#M49793</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;OK. Here is :&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;
data x;
input t (d1 d2 d3) (:&amp;nbsp; ddmmyy10.);
format &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;d1 d2 d3 ddmmyy10.;
cards;
1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;12/03/2002&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;02/02/2012&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;01/01/1960&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
2&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;01/11/2009&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;2/10/2011&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;01/01/1960&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
2&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;21/08/2013&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;29/03/2012&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;2/10/2012
1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;11/10/2015&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;01/01/1960&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;26/12/2014
;
run;
data want;
 set x;
 min=999999;
array x{*} d: ;
do i=1 to dim(x);
if x{i} lt min&amp;nbsp; and x{i} ne 0 then min=x{i};
end;
format min ddmmyy10.;
drop i;
run;
&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Xia Keshan&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 18 Apr 2015 11:21:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Return-min-date-from-multiple-columns-that-is-not-zero/m-p/199229#M49793</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2015-04-18T11:21:54Z</dc:date>
    </item>
  </channel>
</rss>

