<?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: Proc SQL Replace Null With Another Field Value in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Proc-SQL-Replace-Null-With-Another-Field-Value/m-p/548523#M8543</link>
    <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Select a.Acct
,a.EntryDte
,case b.PostDte when . then a.EntryDte else min(b.PostDte) end as PostDate&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Thu, 04 Apr 2019 14:50:33 GMT</pubDate>
    <dc:creator>PaigeMiller</dc:creator>
    <dc:date>2019-04-04T14:50:33Z</dc:date>
    <item>
      <title>Proc SQL Replace Null With Another Field Value</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Proc-SQL-Replace-Null-With-Another-Field-Value/m-p/548510#M8535</link>
      <description>&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to select the min of a date and then if it is null I would like to replace it with the value of another date field:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Select&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;a.Acct&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;,a.EntryDte&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;,&lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;case&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; b.PostDte &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;when&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; null &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;then&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; a.EntryDte &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;else&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; min(b.PostDte) &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;end&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;as&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; PostDate&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;from&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&amp;nbsp;tableA A&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;left&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; outer join&amp;nbsp;tableB B&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;on&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; A.Nbr = B.Nbr&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;group&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;by&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; a.Acct, a.EntryDte&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;while it is grouping the way I want (the b.PostDte has several values per account number), my desired field PostDate is still showing up as null and not the EntryDte (01APR2019)&amp;nbsp;e.g.:&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;acct&amp;nbsp;&amp;nbsp; EntryDte&amp;nbsp;&amp;nbsp;&amp;nbsp; PostDate&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;123&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;01APR2019&amp;nbsp;&amp;nbsp;&amp;nbsp; null&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;456&amp;nbsp;&amp;nbsp;&amp;nbsp; 01APR2019&amp;nbsp;&amp;nbsp;&amp;nbsp; 14MAR2019&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;Any insight is appreciated!&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;I have tried this in SAS EG with a proc SQL&amp;nbsp;as well as an SQL program without any luck.&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 04 Apr 2019 14:29:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Proc-SQL-Replace-Null-With-Another-Field-Value/m-p/548510#M8535</guid>
      <dc:creator>eaherbst</dc:creator>
      <dc:date>2019-04-04T14:29:52Z</dc:date>
    </item>
    <item>
      <title>Re: Proc SQL Replace Null With Another Field Value</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Proc-SQL-Replace-Null-With-Another-Field-Value/m-p/548518#M8541</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/248412"&gt;@eaherbst&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Select&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;a.Acct&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;,a.EntryDte&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;,&lt;/FONT&gt;&lt;FONT face="Courier New" size="3" color="#0000ff"&gt;case&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; b.PostDte &lt;/FONT&gt;&lt;FONT face="Courier New" size="3" color="#0000ff"&gt;when&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; null &lt;/FONT&gt;&lt;FONT face="Courier New" size="3" color="#0000ff"&gt;then&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; a.EntryDte &lt;/FONT&gt;&lt;FONT face="Courier New" size="3" color="#0000ff"&gt;else&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; min(b.PostDte) &lt;/FONT&gt;&lt;FONT face="Courier New" size="3" color="#0000ff"&gt;end&lt;/FONT&gt; &lt;FONT face="Courier New" size="3" color="#0000ff"&gt;as&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; PostDate&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3" color="#0000ff"&gt;from&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&amp;nbsp;tableA A&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3" color="#0000ff"&gt;left&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; outer join&amp;nbsp;tableB B&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3" color="#0000ff"&gt;on&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; A.Nbr = B.Nbr&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3" color="#0000ff"&gt;group&lt;/FONT&gt; &lt;FONT face="Courier New" size="3" color="#0000ff"&gt;by&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; a.Acct, a.EntryDte&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;while it is grouping the way I want (the b.PostDte has several values per account number), my desired field PostDate is still showing up as null and not the EntryDte (01APR2019)&amp;nbsp;e.g.:&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;acct&amp;nbsp;&amp;nbsp; EntryDte&amp;nbsp;&amp;nbsp;&amp;nbsp; PostDate&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;123&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;01APR2019&amp;nbsp;&amp;nbsp;&amp;nbsp; null&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;456&amp;nbsp;&amp;nbsp;&amp;nbsp; 01APR2019&amp;nbsp;&amp;nbsp;&amp;nbsp; 14MAR2019&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Confusing, to be sure. In the last table, it shows the four letters "null" (without the quotes). Did you type it in that way, or is that what actually is produced? If that is what actually is produced, is that a format, or is the variable PostDate a character variable?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I'm thinking you have a format that produces the letter null, but it would be nice to know for sure.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I also point out that if PostDate is missing, then min(b.PostDte) is also a missing.&lt;/P&gt;</description>
      <pubDate>Thu, 04 Apr 2019 14:36:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Proc-SQL-Replace-Null-With-Another-Field-Value/m-p/548518#M8541</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2019-04-04T14:36:40Z</dc:date>
    </item>
    <item>
      <title>Re: Proc SQL Replace Null With Another Field Value</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Proc-SQL-Replace-Null-With-Another-Field-Value/m-p/548520#M8542</link>
      <description>&lt;P&gt;I typed in null, it actually shows up as '.' in SAS so it is not a formatting issue. I understand min(PostDte) would be missing if PostDte is missing, regardless, I would like&amp;nbsp;PostDte (or min(PostDte)&amp;nbsp;to show up as EntryDte if it is missing.&lt;/P&gt;</description>
      <pubDate>Thu, 04 Apr 2019 14:44:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Proc-SQL-Replace-Null-With-Another-Field-Value/m-p/548520#M8542</guid>
      <dc:creator>eaherbst</dc:creator>
      <dc:date>2019-04-04T14:44:59Z</dc:date>
    </item>
    <item>
      <title>Re: Proc SQL Replace Null With Another Field Value</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Proc-SQL-Replace-Null-With-Another-Field-Value/m-p/548523#M8543</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Select a.Acct
,a.EntryDte
,case b.PostDte when . then a.EntryDte else min(b.PostDte) end as PostDate&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 04 Apr 2019 14:50:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Proc-SQL-Replace-Null-With-Another-Field-Value/m-p/548523#M8543</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2019-04-04T14:50:33Z</dc:date>
    </item>
    <item>
      <title>Re: Proc SQL Replace Null With Another Field Value</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Proc-SQL-Replace-Null-With-Another-Field-Value/m-p/548524#M8544</link>
      <description>&lt;BR /&gt;&lt;BR /&gt;COALESCE() is a function to replace missing with a value. &lt;BR /&gt;Try the following and if it doesn't work, consider first summarizing/joining and then filling in the missing data.&lt;BR /&gt;&lt;BR /&gt;select ..., &lt;BR /&gt;min(b.postdte) as min_date, &lt;BR /&gt;min(EntryDte) as min_entry,&lt;BR /&gt;coalesce(calculated min_date, calculated min_entry) as POstDate&lt;BR /&gt;&lt;BR /&gt;The problem here is you're using MINDATE which is a summary statistics of a column and are also referencing Entry date, which you're not using as an aggregate statistics. If you know it's the same across the group you're fine.</description>
      <pubDate>Thu, 04 Apr 2019 14:52:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Proc-SQL-Replace-Null-With-Another-Field-Value/m-p/548524#M8544</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2019-04-04T14:52:34Z</dc:date>
    </item>
    <item>
      <title>Re: Proc SQL Replace Null With Another Field Value</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Proc-SQL-Replace-Null-With-Another-Field-Value/m-p/548533#M8549</link>
      <description>&lt;P&gt;Thank you for the suggestion of using coalesce! I have gotten the desired results with the following code:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Select&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;a.Acct&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;,a.EntryDte&lt;/P&gt;&lt;P&gt;,coalesce(min(&lt;FONT face="Courier New" size="3"&gt;b.PostDte), min(a.EntryDte)) as PostDate&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 04 Apr 2019 15:09:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Proc-SQL-Replace-Null-With-Another-Field-Value/m-p/548533#M8549</guid>
      <dc:creator>eaherbst</dc:creator>
      <dc:date>2019-04-04T15:09:24Z</dc:date>
    </item>
  </channel>
</rss>

