<?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: Convert Datetime to date in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Convert-Datetime-to-date/m-p/647270#M193691</link>
    <description>Can you post sample data please.</description>
    <pubDate>Wed, 13 May 2020 00:01:51 GMT</pubDate>
    <dc:creator>sustagens</dc:creator>
    <dc:date>2020-05-13T00:01:51Z</dc:date>
    <item>
      <title>Convert Datetime to date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Convert-Datetime-to-date/m-p/647268#M193690</link>
      <description>&lt;P&gt;I have the following code. I've created two new variables ReceivedDate and StartDate and if these do not match, I'd like the value of 'PREBOOKED" to be returned. below is my code and 'PREBOOKED" is being returned in every instance, as it appears as though it's reading the above variables as Datetime.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The data source is from an excel spreadsheet.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I've searched this forum and I'm using datepart in my coded, but it appears I'm using it incorrectly.&lt;/P&gt;&lt;PRE&gt;data WORK.IIS_Testa;
	
	set WORK.IIS_Test ;

	ReceivedDate=datepart(Received);
	format ReceivedDate ddmmyyp10.;

	StartDate=datepart('Required Start'n);
	format StartDate ddmmyyp10.;

	

run ;

data WORK.IIS_Testb;
	set WORK.IIS_Testa;
	if  ReceivedDate &amp;lt;&amp;gt; StartDate then Services ='PREBOOKED';
	
run;&lt;/PRE&gt;</description>
      <pubDate>Tue, 12 May 2020 23:53:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Convert-Datetime-to-date/m-p/647268#M193690</guid>
      <dc:creator>Haydn</dc:creator>
      <dc:date>2020-05-12T23:53:03Z</dc:date>
    </item>
    <item>
      <title>Re: Convert Datetime to date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Convert-Datetime-to-date/m-p/647270#M193691</link>
      <description>Can you post sample data please.</description>
      <pubDate>Wed, 13 May 2020 00:01:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Convert-Datetime-to-date/m-p/647270#M193691</guid>
      <dc:creator>sustagens</dc:creator>
      <dc:date>2020-05-13T00:01:51Z</dc:date>
    </item>
    <item>
      <title>Re: Convert Datetime to date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Convert-Datetime-to-date/m-p/647271#M193692</link>
      <description>This what is being returned&lt;BR /&gt;&lt;BR /&gt;Received Required Start&lt;BR /&gt;03MAR20:10:36:02 03MAR20:10:40:00&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;ReceivedDate StartDate&lt;BR /&gt;03.03.2020 03.03.2020</description>
      <pubDate>Wed, 13 May 2020 00:03:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Convert-Datetime-to-date/m-p/647271#M193692</guid>
      <dc:creator>Haydn</dc:creator>
      <dc:date>2020-05-13T00:03:46Z</dc:date>
    </item>
    <item>
      <title>Re: Convert Datetime to date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Convert-Datetime-to-date/m-p/647277#M193694</link>
      <description>&lt;P&gt;Your code is correct.&lt;/P&gt;
&lt;P&gt;You say that "&lt;SPAN&gt;&amp;nbsp;&lt;EM&gt;'PREBOOKED" is being returned in every instance&lt;/EM&gt;&lt;/SPAN&gt;" but&lt;/P&gt;
&lt;P&gt;your output displays only&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;ReceivedDate StartDate
03.03.2020 03.03.2020&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;you did not display the services value.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please post the output of:&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc print data=IIS_Testb;&amp;nbsp; run;&amp;nbsp; &amp;nbsp;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;to show us the issue you claimed.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 13 May 2020 00:45:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Convert-Datetime-to-date/m-p/647277#M193694</guid>
      <dc:creator>Shmuel</dc:creator>
      <dc:date>2020-05-13T00:45:09Z</dc:date>
    </item>
    <item>
      <title>Re: Convert Datetime to date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Convert-Datetime-to-date/m-p/647293#M193701</link>
      <description>&lt;P&gt;Why are you using the MAX operator in your IF statement?&amp;nbsp; That will test if largest date not zero or missing.&lt;/P&gt;
&lt;P&gt;Perhaps you intended to test if they were not equal instead?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if  ReceivedDate  ne StartDate then Services ='PREBOOKED';
if  not (ReceivedDate  = StartDate) then Services ='PREBOOKED';
if  ReceivedDate ^= StartDate then Services ='PREBOOKED';&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 13 May 2020 02:38:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Convert-Datetime-to-date/m-p/647293#M193701</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2020-05-13T02:38:15Z</dc:date>
    </item>
    <item>
      <title>Re: Convert Datetime to date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Convert-Datetime-to-date/m-p/647319#M193715</link>
      <description>&lt;P&gt;Maxim 2: Read the Log:&lt;/P&gt;
&lt;PRE&gt; 96         data WORK.IIS_Testb;
 97         set WORK.IIS_Testa;
 98         if  ReceivedDate &amp;lt;&amp;gt; StartDate then Services ='PREBOOKED';
 NOTE: The "&amp;lt;&amp;gt;" operator is interpreted as "MAX".
 99         
 100        run;
&lt;/PRE&gt;
&lt;P&gt;That's why I prefer to use the "ne" mnemonic for a check for unequal.&lt;/P&gt;</description>
      <pubDate>Wed, 13 May 2020 06:11:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Convert-Datetime-to-date/m-p/647319#M193715</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-05-13T06:11:32Z</dc:date>
    </item>
  </channel>
</rss>

