<?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 Invalid (or missing) arguments to the DATEPART function have caused the function to return in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Invalid-or-missing-arguments-to-the-DATEPART-function-have/m-p/574344#M162268</link>
    <description>&lt;P&gt;To Whom it may concern:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to do a full join and below is my syntax:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
	create table Monthly as 
		SELECT c.*, d.*
			FROM careods.Care_deaths c Full Join Mthdthrp.dthr717 d
				on input(c.care_id, $8.) = d.care_id and c.lastup_DT = d.DOS 
					order datepart(c.lastup_DT) Between '17JUL2018'd and '17JUL2019'd;
QUIT;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;when I execute the code, is get this feedback:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;611  proc sql;
612      create table Monthly as
613          SELECT c.*, d.*
614              FROM careods.Care_deaths c Full Join Mthdthrp.dthr717 d
615                  on input(c.care_id, $8.) = d.care_id and c.lastup_DT = d.DOS
616                      order datepart(c.lastup_DT) Between '17JUL2018'd and '17JUL2019'd;
NOTE: The query as specified involves ordering by an item that doesn't appear in its SELECT
      clause.
WARNING: Variable CARE_ID already exists on file WORK.MONTHLY.
WARNING: Variable Autopsy already exists on file WORK.MONTHLY.

NOTE: Invalid (or missing) arguments to the DATEPART function have caused the function to return
      a missing value.


NOTE: Table WORK.MONTHLY created, with 17765 rows and 56 columns.

617  QUIT;
NOTE: PROCEDURE SQL used (Total process time):
      real time           1.30 seconds
      cpu time            0.20 seconds

&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;'invalid (or missing) argument to the datepart function have caused the function to return a missing value'&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please help!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 17 Jul 2019 19:38:28 GMT</pubDate>
    <dc:creator>RB3</dc:creator>
    <dc:date>2019-07-17T19:38:28Z</dc:date>
    <item>
      <title>Invalid (or missing) arguments to the DATEPART function have caused the function to return</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Invalid-or-missing-arguments-to-the-DATEPART-function-have/m-p/574344#M162268</link>
      <description>&lt;P&gt;To Whom it may concern:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to do a full join and below is my syntax:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
	create table Monthly as 
		SELECT c.*, d.*
			FROM careods.Care_deaths c Full Join Mthdthrp.dthr717 d
				on input(c.care_id, $8.) = d.care_id and c.lastup_DT = d.DOS 
					order datepart(c.lastup_DT) Between '17JUL2018'd and '17JUL2019'd;
QUIT;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;when I execute the code, is get this feedback:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;611  proc sql;
612      create table Monthly as
613          SELECT c.*, d.*
614              FROM careods.Care_deaths c Full Join Mthdthrp.dthr717 d
615                  on input(c.care_id, $8.) = d.care_id and c.lastup_DT = d.DOS
616                      order datepart(c.lastup_DT) Between '17JUL2018'd and '17JUL2019'd;
NOTE: The query as specified involves ordering by an item that doesn't appear in its SELECT
      clause.
WARNING: Variable CARE_ID already exists on file WORK.MONTHLY.
WARNING: Variable Autopsy already exists on file WORK.MONTHLY.

NOTE: Invalid (or missing) arguments to the DATEPART function have caused the function to return
      a missing value.


NOTE: Table WORK.MONTHLY created, with 17765 rows and 56 columns.

617  QUIT;
NOTE: PROCEDURE SQL used (Total process time):
      real time           1.30 seconds
      cpu time            0.20 seconds

&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;'invalid (or missing) argument to the datepart function have caused the function to return a missing value'&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please help!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 17 Jul 2019 19:38:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Invalid-or-missing-arguments-to-the-DATEPART-function-have/m-p/574344#M162268</guid>
      <dc:creator>RB3</dc:creator>
      <dc:date>2019-07-17T19:38:28Z</dc:date>
    </item>
    <item>
      <title>Re: Invalid (or missing) arguments to the DATEPART function have caused the function to return</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Invalid-or-missing-arguments-to-the-DATEPART-function-have/m-p/574346#M162269</link>
      <description>&lt;P&gt;to add to my previous statement, my return comes back with NULLS, and I want all the records to show.&lt;/P&gt;</description>
      <pubDate>Wed, 17 Jul 2019 19:39:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Invalid-or-missing-arguments-to-the-DATEPART-function-have/m-p/574346#M162269</guid>
      <dc:creator>RB3</dc:creator>
      <dc:date>2019-07-17T19:39:52Z</dc:date>
    </item>
    <item>
      <title>Re: Invalid (or missing) arguments to the DATEPART function have caused the function to return</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Invalid-or-missing-arguments-to-the-DATEPART-function-have/m-p/574347#M162270</link>
      <description>&lt;P&gt;This is incorrect i think&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE class=" language-sas"&gt;&lt;CODE class="  language-sas"&gt; &lt;SPAN class="token keyword"&gt;input&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;c&lt;SPAN class="token punctuation"&gt;.&lt;/SPAN&gt;care_id&lt;SPAN class="token punctuation"&gt;,&lt;/SPAN&gt; &lt;SPAN class="token punctuation"&gt;$&lt;/SPAN&gt;&lt;SPAN class="token number"&gt;8&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;.&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;should be &lt;STRONG&gt;without&lt;/STRONG&gt; the $&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE class=" language-sas"&gt;&lt;CODE class="  language-sas"&gt; &lt;SPAN class="token keyword"&gt;input&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;c&lt;SPAN class="token punctuation"&gt;.&lt;/SPAN&gt;care_id&lt;SPAN class="token punctuation"&gt;,&lt;/SPAN&gt; &lt;SPAN class="token number"&gt;8&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;.&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Also no idea what's your objective here&amp;nbsp;&lt;/P&gt;
&lt;PRE class=" language-sas"&gt;&lt;CODE class="  language-sas"&gt;order &lt;SPAN class="token function"&gt;datepart&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;c&lt;SPAN class="token punctuation"&gt;.&lt;/SPAN&gt;lastup_DT&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt; Between &lt;SPAN class="token datetime number"&gt;'17JUL2018'd&lt;/SPAN&gt; and &lt;SPAN class="token datetime number"&gt;'17JUL2019'd&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 17 Jul 2019 19:44:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Invalid-or-missing-arguments-to-the-DATEPART-function-have/m-p/574347#M162270</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2019-07-17T19:44:07Z</dc:date>
    </item>
    <item>
      <title>Re: Invalid (or missing) arguments to the DATEPART function have caused the function to return</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Invalid-or-missing-arguments-to-the-DATEPART-function-have/m-p/574348#M162271</link>
      <description>&lt;P&gt;Are you really trying to order based on whether the date falls in some interval or not?&amp;nbsp; Where to you want the values that are missing to fall?&amp;nbsp; Before the false values?&amp;nbsp; Or after the true values?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can use a CASE statement to skip the function when the value is missing.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
create table Monthly as
SELECT c.*, d.*
FROM careods.Care_deaths c
Full Join Mthdthrp.dthr717 d
on input(c.care_id, $8.) = d.care_id
 and c.lastup_DT = d.DOS
order case when missing(c.lastup_dt) then -1
      else   datepart(c.lastup_DT) Between '17JUL2018'd and '17JUL2019'd
      end
;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Also note that there is no need to use INPUT() function to take the first 8 characters of a string. You can use SUBSTR() or SUBSTRN() for that.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 17 Jul 2019 19:44:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Invalid-or-missing-arguments-to-the-DATEPART-function-have/m-p/574348#M162271</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-07-17T19:44:56Z</dc:date>
    </item>
    <item>
      <title>Re: Invalid (or missing) arguments to the DATEPART function have caused the function to return</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Invalid-or-missing-arguments-to-the-DATEPART-function-have/m-p/574360#M162274</link>
      <description>&lt;P&gt;The line&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;order datepart(c.lastup_DT) Between '17JUL2018'd and '17JUL2019'd;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;forces the rows between those dates to the bottom of the output - don't you mean&amp;nbsp;&lt;EM&gt;where&lt;/EM&gt; instead of&amp;nbsp;&lt;EM&gt;order?&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Assuming that you do, this would be better:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;where c.lastup_DT Between '17JUL2018:0:0'dt and '17JUL2019:23:59:59'dt;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;That way any null values won't trigger, and there won't be any warning messages.&lt;/P&gt;</description>
      <pubDate>Wed, 17 Jul 2019 20:40:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Invalid-or-missing-arguments-to-the-DATEPART-function-have/m-p/574360#M162274</guid>
      <dc:creator>LaurieF</dc:creator>
      <dc:date>2019-07-17T20:40:56Z</dc:date>
    </item>
    <item>
      <title>Re: Invalid (or missing) arguments to the DATEPART function have caused the function to return</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Invalid-or-missing-arguments-to-the-DATEPART-function-have/m-p/574481#M162340</link>
      <description>&lt;P&gt;Or could it be that somehow "or" mutated to "order"?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And your use of asterisks for both datasets is bound to cause a WARNING, which must not be tolerated (see Maxims 24 &amp;amp; 25) .&lt;/P&gt;
&lt;P&gt;At least for dataset&amp;nbsp;&lt;/P&gt;
&lt;PRE class=" language-sas"&gt;&lt;CODE class="  language-sas"&gt;Mthdthrp&lt;SPAN class="token punctuation"&gt;.&lt;/SPAN&gt;dthr717&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;be more selective to avoid the WARNING.&lt;/P&gt;</description>
      <pubDate>Thu, 18 Jul 2019 08:05:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Invalid-or-missing-arguments-to-the-DATEPART-function-have/m-p/574481#M162340</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2019-07-18T08:05:30Z</dc:date>
    </item>
  </channel>
</rss>

