<?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: Choose the earlist date from five date variables in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Choose-the-earlist-date-from-five-date-variables/m-p/881444#M348287</link>
    <description>&lt;P&gt;Sometimes, all you need to do is check the &lt;A href="https://documentation.sas.com/doc/en/pgmmvacdc/9.4/lefunctionsref/p1525p9momafkwn15gm707mtsbat.htm" target="_self"&gt;documentation for the MIN function&lt;/A&gt;. It specifically answers your question:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;"The MIN function returns a missing value (.) only if all arguments are missing."&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Since you said: "The new variable was created, but all the values are missing" then your data must have problems in it. Show us data set DF as working SAS data step code (&lt;A href="https://blogs.sas.com/content/sastraining/2016/03/11/jedi-sas-tricks-data-to-data-step-macro/" target="_self"&gt;instructions and examples&lt;/A&gt;) and not in any other form. Are there errors or warnings or other problems in the log?&lt;/P&gt;</description>
    <pubDate>Mon, 19 Jun 2023 19:23:56 GMT</pubDate>
    <dc:creator>PaigeMiller</dc:creator>
    <dc:date>2023-06-19T19:23:56Z</dc:date>
    <item>
      <title>Choose the earlist date from five date variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Choose-the-earlist-date-from-five-date-variables/m-p/881442#M348286</link>
      <description>&lt;P&gt;How can I choose the earliest date from a list of variables, and create a new variable save the earliest date. The missing values are saved as "." for these 5 variables.&amp;nbsp;&lt;/P&gt;&lt;P&gt;The missing values should be ignored when comparing. Only if 5 date variables are&amp;nbsp; all missing, the new variable will be saved as a missing value.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The code I wrote:&lt;/P&gt;&lt;P&gt;data df1;&lt;/P&gt;&lt;P&gt;set df;&lt;/P&gt;&lt;P&gt;earliest=min(of date_a date_b date_c date_d date_e);&lt;/P&gt;&lt;P&gt;format earliest mmddyy10.;&lt;/P&gt;&lt;P&gt;run;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The new variable was created, but all the values are missing.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 19 Jun 2023 19:13:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Choose-the-earlist-date-from-five-date-variables/m-p/881442#M348286</guid>
      <dc:creator>L777</dc:creator>
      <dc:date>2023-06-19T19:13:44Z</dc:date>
    </item>
    <item>
      <title>Re: Choose the earlist date from five date variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Choose-the-earlist-date-from-five-date-variables/m-p/881444#M348287</link>
      <description>&lt;P&gt;Sometimes, all you need to do is check the &lt;A href="https://documentation.sas.com/doc/en/pgmmvacdc/9.4/lefunctionsref/p1525p9momafkwn15gm707mtsbat.htm" target="_self"&gt;documentation for the MIN function&lt;/A&gt;. It specifically answers your question:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;"The MIN function returns a missing value (.) only if all arguments are missing."&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Since you said: "The new variable was created, but all the values are missing" then your data must have problems in it. Show us data set DF as working SAS data step code (&lt;A href="https://blogs.sas.com/content/sastraining/2016/03/11/jedi-sas-tricks-data-to-data-step-macro/" target="_self"&gt;instructions and examples&lt;/A&gt;) and not in any other form. Are there errors or warnings or other problems in the log?&lt;/P&gt;</description>
      <pubDate>Mon, 19 Jun 2023 19:23:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Choose-the-earlist-date-from-five-date-variables/m-p/881444#M348287</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2023-06-19T19:23:56Z</dc:date>
    </item>
    <item>
      <title>Re: Choose the earlist date from five date variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Choose-the-earlist-date-from-five-date-variables/m-p/881445#M348288</link>
      <description>&lt;P&gt;Not sure you're using OF correctly here.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;earliest=min(date_a, date_b, date_c, date_d, date_e);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Does that also return the same results? If so, something is either wrong with the data or logic.&lt;/P&gt;</description>
      <pubDate>Mon, 19 Jun 2023 19:18:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Choose-the-earlist-date-from-five-date-variables/m-p/881445#M348288</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2023-06-19T19:18:55Z</dc:date>
    </item>
    <item>
      <title>Re: Choose the earlist date from five date variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Choose-the-earlist-date-from-five-date-variables/m-p/881461#M348291</link>
      <description>I tried that. But there is an error: Expecting an arithmetic operator if not include "of".</description>
      <pubDate>Mon, 19 Jun 2023 20:27:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Choose-the-earlist-date-from-five-date-variables/m-p/881461#M348291</guid>
      <dc:creator>L777</dc:creator>
      <dc:date>2023-06-19T20:27:37Z</dc:date>
    </item>
    <item>
      <title>Re: Choose the earlist date from five date variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Choose-the-earlist-date-from-five-date-variables/m-p/881464#M348292</link>
      <description>&lt;P&gt;There are no warnings or errors in log. But there are some note like:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;NOTE: Character values have been converted to numeric values at the places given by: (Line):(Column).&lt;BR /&gt;16:27 16:48 16:67 16:88 16:105&lt;BR /&gt;NOTE: Invalid numeric data, rx_summ_dt_radiation='9/17/2013' , at line 16 column 27.&lt;BR /&gt;NOTE: Invalid numeric data, rx_summ_date_chemo='5/10/2013' , at line 16 column 48.&lt;BR /&gt;NOTE: Invalid numeric data, rx_summ_date_hormone='8/26/2013' , at line 16 column 67.&lt;BR /&gt;NOTE: Invalid numeric data, rx_summ_date_transplnt_endocr_da='0/0/0' , at line 16 column 105.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Do I need to convert the format of the date before using the min function?&lt;/P&gt;</description>
      <pubDate>Mon, 19 Jun 2023 20:34:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Choose-the-earlist-date-from-five-date-variables/m-p/881464#M348292</guid>
      <dc:creator>L777</dc:creator>
      <dc:date>2023-06-19T20:34:48Z</dc:date>
    </item>
    <item>
      <title>Re: Choose the earlist date from five date variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Choose-the-earlist-date-from-five-date-variables/m-p/881466#M348293</link>
      <description>Yes, you have character variables. Dates need to be numeric before they can be 'ordered'.  &lt;BR /&gt;&lt;BR /&gt;Rough idea - you'll need to list out your variables yourself. &lt;BR /&gt;&lt;BR /&gt;data want;&lt;BR /&gt;set have;&lt;BR /&gt;&lt;BR /&gt;array _old(*) $10. rx_summ_dt_radiation ....;&lt;BR /&gt;array _new(*) dt_radiation dt_chemo ...;&lt;BR /&gt;&lt;BR /&gt;do i=1 to dim(_old);&lt;BR /&gt;_new(i) = input(_old(i), mmddyy10.);&lt;BR /&gt;end;&lt;BR /&gt;&lt;BR /&gt;format dt_: date9.;&lt;BR /&gt;run;&lt;BR /&gt;</description>
      <pubDate>Mon, 19 Jun 2023 20:40:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Choose-the-earlist-date-from-five-date-variables/m-p/881466#M348293</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2023-06-19T20:40:30Z</dc:date>
    </item>
    <item>
      <title>Re: Choose the earlist date from five date variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Choose-the-earlist-date-from-five-date-variables/m-p/881467#M348294</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/444323"&gt;@L777&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;There are no warnings or errors in log. But there are some note like:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;NOTE: Character values have been converted to numeric values at the places given by: (Line):(Column).&lt;BR /&gt;16:27 16:48 16:67 16:88 16:105&lt;BR /&gt;NOTE: Invalid numeric data, rx_summ_dt_radiation='9/17/2013' , at line 16 column 27.&lt;BR /&gt;NOTE: Invalid numeric data, rx_summ_date_chemo='5/10/2013' , at line 16 column 48.&lt;BR /&gt;NOTE: Invalid numeric data, rx_summ_date_hormone='8/26/2013' , at line 16 column 67.&lt;BR /&gt;NOTE: Invalid numeric data, rx_summ_date_transplnt_endocr_da='0/0/0' , at line 16 column 105.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Do I need to convert the format of the date before using the min function?&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;To use correct SAS terminology, this is not a "format" issue at all. It is the fact that dates need to be numeric, not character. This is the variable "type" and not "format". In SAS, there are only two variable types, numeric and character.&lt;/P&gt;</description>
      <pubDate>Mon, 19 Jun 2023 21:05:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Choose-the-earlist-date-from-five-date-variables/m-p/881467#M348294</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2023-06-19T21:05:19Z</dc:date>
    </item>
    <item>
      <title>Re: Choose the earlist date from five date variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Choose-the-earlist-date-from-five-date-variables/m-p/881468#M348295</link>
      <description>&lt;P&gt;Quoting error messages without the code that caused it isn't useful. So we can see what is happening you need to post the COMPLETE SAS log of your DATA step containing both code and any errors or notes.&lt;/P&gt;</description>
      <pubDate>Mon, 19 Jun 2023 21:11:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Choose-the-earlist-date-from-five-date-variables/m-p/881468#M348295</guid>
      <dc:creator>SASKiwi</dc:creator>
      <dc:date>2023-06-19T21:11:30Z</dc:date>
    </item>
    <item>
      <title>Re: Choose the earlist date from five date variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Choose-the-earlist-date-from-five-date-variables/m-p/881475#M348296</link>
      <description>&lt;P&gt;&amp;nbsp;I tried this code, but there is warning:&lt;/P&gt;&lt;P&gt;NOTE: Invalid argument to function INPUT at line 12 column 11.&lt;BR /&gt;WARNING: Limit set by ERRORS= option reached. Further errors of this type will not be printed.&lt;/P&gt;</description>
      <pubDate>Mon, 19 Jun 2023 22:06:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Choose-the-earlist-date-from-five-date-variables/m-p/881475#M348296</guid>
      <dc:creator>L777</dc:creator>
      <dc:date>2023-06-19T22:06:29Z</dc:date>
    </item>
    <item>
      <title>Re: Choose the earlist date from five date variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Choose-the-earlist-date-from-five-date-variables/m-p/881476#M348297</link>
      <description>&lt;P&gt;I finally create the new variable based on your code. Thank you!&lt;/P&gt;</description>
      <pubDate>Mon, 19 Jun 2023 22:20:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Choose-the-earlist-date-from-five-date-variables/m-p/881476#M348297</guid>
      <dc:creator>L777</dc:creator>
      <dc:date>2023-06-19T22:20:08Z</dc:date>
    </item>
    <item>
      <title>Re: Choose the earlist date from five date variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Choose-the-earlist-date-from-five-date-variables/m-p/881477#M348298</link>
      <description>Please post the full code used and the log. If you have some variables as dates and some as character that's also one possible issue.</description>
      <pubDate>Mon, 19 Jun 2023 22:21:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Choose-the-earlist-date-from-five-date-variables/m-p/881477#M348298</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2023-06-19T22:21:42Z</dc:date>
    </item>
    <item>
      <title>Re: Choose the earlist date from five date variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Choose-the-earlist-date-from-five-date-variables/m-p/881478#M348299</link>
      <description>Glad it worked for you!</description>
      <pubDate>Mon, 19 Jun 2023 22:27:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Choose-the-earlist-date-from-five-date-variables/m-p/881478#M348299</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2023-06-19T22:27:39Z</dc:date>
    </item>
  </channel>
</rss>

