<?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 Date Format in SAS Enterprise Guide</title>
    <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Date-Format/m-p/151094#M11843</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm just trying to compare against certain columns from two datasets. One of these is derived from SQL database extraction and the other is a SAS dataset. The issue has been with the date variables. The 'rule_result_date' variable from the SAS dataset has an original format of ddmmmyy:hh:mm:ss, whilst the 'CDT' variable has a format of ddmmmyyyy from the SQL excel dataset. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;With the code below, I have managed to format the 'rule_result_variable' (which has been renamed as Date) into ddmmmyyyy. However the issue arises in the section when creating the final table 'Allign'. I am trying to compare both dates (i.e Date and CDT) by adding a new column 'Date_Equal' to show which dates are equal, denoted by either a '1' for equivalence or '0'&amp;nbsp; for non-equivalence. However the 'Date_Equal' column is just returning all zeroes, despite the fact by visual observation I can see the dates are clearly equal.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Would really appreciate some help on the matter.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have attached a screenshot of the 'Allign' table output to demonstrate the problem.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;/* Import the SQL raw dataset */&lt;BR /&gt;proc import datafile= 'E:\SAS_BI\CFAD\AP\Data\Rules.xlsx'&lt;BR /&gt;out= SIRA &lt;BR /&gt;dbms= excel&lt;BR /&gt;replace;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;/* SAS Dataset */&lt;/P&gt;&lt;P&gt;Data SAS_Extract;&lt;BR /&gt;Set SIRA.SIRA_SCORES;&lt;BR /&gt;policy_number_1 = substr(application_number,verify(application_number,'0')); &lt;BR /&gt;date = datepart(rule_result_date);&lt;BR /&gt;format date $DATE9.;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data SIRA_NEW;&lt;BR /&gt;set SIRA;&lt;BR /&gt;date = input(CDT,DATETIME18.);&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc sql;&lt;BR /&gt;create table new as&lt;BR /&gt;select distinct SE.policy_number_1, SE.rule_name, SE.date, SE.rule_result_key &lt;BR /&gt;from SAS_Extract SE&lt;BR /&gt;where date between '01JAN2014'D and '31MAR2014'D&lt;BR /&gt;order by policy_number_1;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc sort data=SIRA_NEW&amp;nbsp; nodupkey;&lt;BR /&gt; by policy_number rule_name CDT;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;/* Merge both datasets using Proc SQL */&lt;/P&gt;&lt;P&gt;Proc sql;&lt;BR /&gt;Create Table Allign as&lt;BR /&gt;Select distinct N.policy_number_1, S.policy_number, N.rule_name as SAS_RN, S.rule_name as SIRA_RN,&lt;BR /&gt;N.date, S.CDT, N.rule_result_key, S.match_Key,&lt;BR /&gt;Case when S.rule_name = N.rule_name then 1 else 0 end as Rule_Equal,&lt;BR /&gt;case when S.CDT = N.date then 1 else 0 end as Date_Equal&lt;BR /&gt;From SIRA_NEW&amp;nbsp; S&lt;BR /&gt;inner join new N&lt;BR /&gt;on S.policy_number = N.policy_number_1;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Proc Freq DATA= Allign;&lt;BR /&gt;Tables SAS_RN*Date_Equal;&lt;BR /&gt;run;&lt;/P&gt;&lt;BR /&gt;&lt;IMG src="https://communities.sas.com/t5/image/serverpage/image-id/11539iD289CB5C5E781A04/image-size/large?v=1.0&amp;amp;px=600" border="0" alt="Allign.JPG" title="Allign.JPG" /&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 03 Feb 2015 16:29:08 GMT</pubDate>
    <dc:creator>ToonKnight</dc:creator>
    <dc:date>2015-02-03T16:29:08Z</dc:date>
    <item>
      <title>Date Format</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Date-Format/m-p/151094#M11843</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm just trying to compare against certain columns from two datasets. One of these is derived from SQL database extraction and the other is a SAS dataset. The issue has been with the date variables. The 'rule_result_date' variable from the SAS dataset has an original format of ddmmmyy:hh:mm:ss, whilst the 'CDT' variable has a format of ddmmmyyyy from the SQL excel dataset. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;With the code below, I have managed to format the 'rule_result_variable' (which has been renamed as Date) into ddmmmyyyy. However the issue arises in the section when creating the final table 'Allign'. I am trying to compare both dates (i.e Date and CDT) by adding a new column 'Date_Equal' to show which dates are equal, denoted by either a '1' for equivalence or '0'&amp;nbsp; for non-equivalence. However the 'Date_Equal' column is just returning all zeroes, despite the fact by visual observation I can see the dates are clearly equal.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Would really appreciate some help on the matter.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have attached a screenshot of the 'Allign' table output to demonstrate the problem.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;/* Import the SQL raw dataset */&lt;BR /&gt;proc import datafile= 'E:\SAS_BI\CFAD\AP\Data\Rules.xlsx'&lt;BR /&gt;out= SIRA &lt;BR /&gt;dbms= excel&lt;BR /&gt;replace;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;/* SAS Dataset */&lt;/P&gt;&lt;P&gt;Data SAS_Extract;&lt;BR /&gt;Set SIRA.SIRA_SCORES;&lt;BR /&gt;policy_number_1 = substr(application_number,verify(application_number,'0')); &lt;BR /&gt;date = datepart(rule_result_date);&lt;BR /&gt;format date $DATE9.;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data SIRA_NEW;&lt;BR /&gt;set SIRA;&lt;BR /&gt;date = input(CDT,DATETIME18.);&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc sql;&lt;BR /&gt;create table new as&lt;BR /&gt;select distinct SE.policy_number_1, SE.rule_name, SE.date, SE.rule_result_key &lt;BR /&gt;from SAS_Extract SE&lt;BR /&gt;where date between '01JAN2014'D and '31MAR2014'D&lt;BR /&gt;order by policy_number_1;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc sort data=SIRA_NEW&amp;nbsp; nodupkey;&lt;BR /&gt; by policy_number rule_name CDT;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;/* Merge both datasets using Proc SQL */&lt;/P&gt;&lt;P&gt;Proc sql;&lt;BR /&gt;Create Table Allign as&lt;BR /&gt;Select distinct N.policy_number_1, S.policy_number, N.rule_name as SAS_RN, S.rule_name as SIRA_RN,&lt;BR /&gt;N.date, S.CDT, N.rule_result_key, S.match_Key,&lt;BR /&gt;Case when S.rule_name = N.rule_name then 1 else 0 end as Rule_Equal,&lt;BR /&gt;case when S.CDT = N.date then 1 else 0 end as Date_Equal&lt;BR /&gt;From SIRA_NEW&amp;nbsp; S&lt;BR /&gt;inner join new N&lt;BR /&gt;on S.policy_number = N.policy_number_1;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Proc Freq DATA= Allign;&lt;BR /&gt;Tables SAS_RN*Date_Equal;&lt;BR /&gt;run;&lt;/P&gt;&lt;BR /&gt;&lt;IMG src="https://communities.sas.com/t5/image/serverpage/image-id/11539iD289CB5C5E781A04/image-size/large?v=1.0&amp;amp;px=600" border="0" alt="Allign.JPG" title="Allign.JPG" /&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 03 Feb 2015 16:29:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Date-Format/m-p/151094#M11843</guid>
      <dc:creator>ToonKnight</dc:creator>
      <dc:date>2015-02-03T16:29:08Z</dc:date>
    </item>
    <item>
      <title>Re: Date Format</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Date-Format/m-p/151095#M11844</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Why are you using CDT from Sira_new instead of the DATE variable you created? CDT is either text or a numeric that looks like a datetime and would not be the date?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 03 Feb 2015 17:27:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Date-Format/m-p/151095#M11844</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2015-02-03T17:27:50Z</dc:date>
    </item>
    <item>
      <title>Re: Date Format</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Date-Format/m-p/151096#M11845</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks for replying really appreciate it.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Apologies, the date variable which was created for sira_new can be marked as invalid, as this produces just an additional numeric variable which is not required.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Originally in excel, the 'rules' spreadsheet contains the 'CDT' variable which was displayed in the following format 'dd/mm/yyyy&amp;nbsp; hh:mm:ss' . This was subsequently formatted on excel to a 'short date' format to output these values in the form 'dd/mm/yyyy'.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;As you can see the 'CDT' variable portrays itself as a date variable when run on SAS. I'm not sure whether setting the 'CDT' variable as 'short date' on excel would make it text or numeric.&amp;nbsp; I want to keep the formats for both 'CDT' (sira) and 'date'(SAS) in the form ddmmmyyyy.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Would I need to refer back and add conditions to the date variable I added for sira_new or would I need to do something else?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 04 Feb 2015 09:53:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Date-Format/m-p/151096#M11845</guid>
      <dc:creator>ToonKnight</dc:creator>
      <dc:date>2015-02-04T09:53:34Z</dc:date>
    </item>
    <item>
      <title>Re: Date Format</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Date-Format/m-p/151097#M11846</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Like excel, SAS&amp;nbsp; can format a datetime value as just the date without creating a new variable via the datepart() function.&lt;/P&gt;&lt;P&gt;Just apply the format DTDATE9. and only the date is shown.&lt;/P&gt;&lt;P&gt;There is no built-in format DTDDMMYY. provided with SAS but you could build one with PROC FORMAT.&lt;/P&gt;&lt;P&gt;When comparing a datetime value with a date constant don't aoply the datepart() function to the value (performance reasons) - just extent the constant in a range test like&lt;/P&gt;&lt;P&gt;where datetime_variable between "&amp;amp;dconst:0:0"dt and "&amp;amp;dateconst:23:59:59"dt&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 06 Feb 2015 08:56:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Date-Format/m-p/151097#M11846</guid>
      <dc:creator>Peter_C</dc:creator>
      <dc:date>2015-02-06T08:56:35Z</dc:date>
    </item>
    <item>
      <title>Re: Date Format</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Date-Format/m-p/151098#M11847</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Format DTDATE9. is nice one. Thank you.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 06 Feb 2015 12:50:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Date-Format/m-p/151098#M11847</guid>
      <dc:creator>ShashikanthRai</dc:creator>
      <dc:date>2015-02-06T12:50:47Z</dc:date>
    </item>
  </channel>
</rss>

