<?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: min Date conversions to character date in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/min-Date-conversions-to-character-date/m-p/746617#M234219</link>
    <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;not in (select cats(id,put(min(year_month),date9.))) from dataset2_2 where new_ind =1)&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Tue, 08 Jun 2021 23:14:56 GMT</pubDate>
    <dc:creator>PaigeMiller</dc:creator>
    <dc:date>2021-06-08T23:14:56Z</dc:date>
    <item>
      <title>min Date conversions to character date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/min-Date-conversions-to-character-date/m-p/746616#M234218</link>
      <description>&lt;P&gt;Hi SAS Users,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I need a help.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am updating a table with PROC SQL syntax and where condition is not working properly.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;year_month value is coming as 01FEB2018 ( a date field) and concatenation needs character conversion , i converted it to&amp;nbsp;put(year_month1,date9.) and looks like&amp;nbsp; ( ABC01FEB2018 which is id ||&amp;nbsp;put(year_month1,date9.)&amp;nbsp; )&lt;/P&gt;
&lt;P&gt;on the right side, i have min(year_month) which is in SAS integer format, i need to convert this into&amp;nbsp; 01FEB2018 format to get the merge correctly.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Or IS there any better way to merge this charcter-date field with min(date) ?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc sql;&lt;BR /&gt;create table dataset2_2 as &lt;BR /&gt;select * from dataset2_1&lt;BR /&gt;;&lt;BR /&gt;update dataset2_1 a &lt;BR /&gt;set new_ind =99 &lt;BR /&gt;where new_ind =1&lt;BR /&gt;and (id ||&amp;nbsp; put(year_month1,date9.)) not in ( select id || min(year_month) from dataset2_2 where new_ind =1)&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;/* not working */&lt;BR /&gt;;&lt;BR /&gt;Quit;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks,&lt;/P&gt;
&lt;P&gt;Ana&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 08 Jun 2021 23:10:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/min-Date-conversions-to-character-date/m-p/746616#M234218</guid>
      <dc:creator>SASAna</dc:creator>
      <dc:date>2021-06-08T23:10:16Z</dc:date>
    </item>
    <item>
      <title>Re: min Date conversions to character date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/min-Date-conversions-to-character-date/m-p/746617#M234219</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;not in (select cats(id,put(min(year_month),date9.))) from dataset2_2 where new_ind =1)&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 08 Jun 2021 23:14:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/min-Date-conversions-to-character-date/m-p/746617#M234219</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2021-06-08T23:14:56Z</dc:date>
    </item>
    <item>
      <title>Re: min Date conversions to character date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/min-Date-conversions-to-character-date/m-p/746619#M234221</link>
      <description>&lt;P&gt;You need to explicitly control all numeric to character conversions. Otherwise SAS will use a best format a likely have a bunch of leading blanks in part of the value especially if using the || operator to concatenate text.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Something like:&amp;nbsp; select&amp;nbsp; ID || Put(min(year_month),date9)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Personally instead of doing the concatenation of values in Dataset2_2 as a sub-query I would create a variable in the first bit:&lt;/P&gt;
&lt;PRE&gt;proc sql;
   create table dataset2_2 as
   select * , cats(id,put(min(year_month),date9.)) as combid
   from dataset2_1
;&lt;/PRE&gt;
&lt;P&gt;And then use the Combid (or whatever) in the update.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 08 Jun 2021 23:22:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/min-Date-conversions-to-character-date/m-p/746619#M234221</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2021-06-08T23:22:36Z</dc:date>
    </item>
    <item>
      <title>Re: min Date conversions to character date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/min-Date-conversions-to-character-date/m-p/746627#M234227</link>
      <description>&lt;P&gt;Not having SAS at my home computer, I am also skeptical if you can use the MIN function inside this type of SELECT clause, but I can't test it out right now. So as much as I hate to admit it, I think &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13884"&gt;@ballardw&lt;/a&gt; is on the right track.&lt;/P&gt;</description>
      <pubDate>Tue, 08 Jun 2021 23:33:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/min-Date-conversions-to-character-date/m-p/746627#M234227</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2021-06-08T23:33:55Z</dc:date>
    </item>
    <item>
      <title>Re: min Date conversions to character date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/min-Date-conversions-to-character-date/m-p/746864#M234349</link>
      <description>Thank you. worked very well.</description>
      <pubDate>Wed, 09 Jun 2021 19:06:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/min-Date-conversions-to-character-date/m-p/746864#M234349</guid>
      <dc:creator>SASAna</dc:creator>
      <dc:date>2021-06-09T19:06:59Z</dc:date>
    </item>
  </channel>
</rss>

