<?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: how to check if the var is date or datetime in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/how-to-check-if-the-var-is-date-or-datetime/m-p/174267#M264547</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If you want to use the formats, function vformat() would be the best way to do it. Something like (this is incomplete) :&lt;/P&gt;&lt;PRE&gt;&lt;SPAN style="color: navy; font-size: 10.0pt; font-family: 'Courier New';"&gt;&lt;STRONG&gt;data&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black;"&gt; T1;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black;"&gt;&amp;nbsp; V=today();&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue;"&gt;output&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black;"&gt;;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black;"&gt;&amp;nbsp; V=datetime();&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue;"&gt;output&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black;"&gt;;&lt;/SPAN&gt;&lt;BR /&gt;&amp;nbsp; &lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue;"&gt;format&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black;"&gt; V &lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: teal;"&gt;datetime.&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black;"&gt;;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="color: navy; font-size: 10.0pt; font-family: 'Courier New';"&gt;&lt;STRONG&gt;data&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black;"&gt; T2;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue;"&gt;&amp;nbsp; set&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black;"&gt; T1; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black;"&gt;&amp;nbsp; F=vformat(V);&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black;"&gt;&amp;nbsp; X= ifn( F =: &lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: purple;"&gt;'DATETIME'&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black;"&gt; or find(F,&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: purple;"&gt;'DT'&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black;"&gt;)&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; , datepart(V)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ,ifn( F in: (&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: purple;"&gt;'YYMM'&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black;"&gt;,&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: purple;"&gt;'DDMM'&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black;"&gt;,&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: purple;"&gt;'MMDD'&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black;"&gt;,&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: purple;"&gt;'DATE'&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black;"&gt;)&amp;nbsp; , V&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ,ifn( V &amp;lt; &lt;/SPAN&gt;&lt;SPAN style="color: teal; font-size: 10.0pt; font-family: 'Courier New';"&gt;&lt;STRONG&gt;25000&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; , V&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ,&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; datepart(V) )));&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue;"&gt;&amp;nbsp; putlog&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black;"&gt; X X &lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: teal;"&gt;date.&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black;"&gt;;&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue;"&gt;&lt;BR /&gt;run&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black;"&gt;;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;P&gt;but using the formatted value directly and leveraging the &lt;SPAN style="color: #008080; background-color: #ffffff;"&gt;anydtdte. &lt;/SPAN&gt;informat as shown by &lt;A _jive_internal="true" href="https://communities.sas.com/people/data_null_;"&gt;data _null_&lt;/A&gt; is the most elegant way.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 19 Feb 2015 20:59:54 GMT</pubDate>
    <dc:creator>ChrisNZ</dc:creator>
    <dc:date>2015-02-19T20:59:54Z</dc:date>
    <item>
      <title>how to check if the var is date or datetime</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-check-if-the-var-is-date-or-datetime/m-p/174258#M264538</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 need to write a macro working on two datasets. They both have variable 'date1', but one if them is real date (eg 2015/01/01) and the other one is datetime (eg 01Jan2015:00:00:00). I want to extract the date part of date1. It is something like&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If it is datetime, then I need to run&amp;nbsp;&amp;nbsp; ---- date2 = datapart(date1);&lt;/P&gt;&lt;P&gt;if it is real date, then I need to run&amp;nbsp;&amp;nbsp; ----- date2 = date1;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;How can I write the condition part of the statement?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 19 Feb 2015 00:09:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-check-if-the-var-is-date-or-datetime/m-p/174258#M264538</guid>
      <dc:creator>swimmer</dc:creator>
      <dc:date>2015-02-19T00:09:51Z</dc:date>
    </item>
    <item>
      <title>Re: how to check if the var is date or datetime</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-check-if-the-var-is-date-or-datetime/m-p/174259#M264539</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Are you working on the data sets separately or is this after/during a merge? If the first I don't see why it is conditional. If you are combining datasets either with merge or set statements then us the IN dataset option:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data want;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; set have1 (in=set1) have2 (in=set2);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if set1 then &amp;lt;code&amp;gt;;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if set2 then &amp;lt;other code&amp;gt;;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Yes could use Else but if you end up combining more sets then ELSE may not be appropriate;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 19 Feb 2015 00:17:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-check-if-the-var-is-date-or-datetime/m-p/174259#M264539</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2015-02-19T00:17:38Z</dc:date>
    </item>
    <item>
      <title>Re: how to check if the var is date or datetime</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-check-if-the-var-is-date-or-datetime/m-p/174260#M264540</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;It works much better if you KNOW which variable is using DATE and which is using DATETIME.&lt;/P&gt;&lt;P&gt;How about looking at the attached format?&lt;/P&gt;&lt;P&gt;Just looking at a single value might not work unless you know specifically what types of dates you expect.&amp;nbsp; But if you are looking a Birth Dates for example then you could have some valid datetime values that fall into the range normally associated with DATE values.&amp;nbsp; You might have some luck looking at the range of values. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;data check ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; do year=-85 to 0 ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; date=intnx('year',today(),year);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; datetime=dhms(date,0,0,0);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; output;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; end;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;run;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;proc summary data=check nway ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; var date datetime;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; output out=ranges range= min= max= /autoname;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;run;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;proc print; run;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; date_&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; datetime_&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; datetime_&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; datetime_&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;Obs&amp;nbsp;&amp;nbsp;&amp;nbsp; _TYPE_&amp;nbsp;&amp;nbsp;&amp;nbsp; _FREQ_&amp;nbsp;&amp;nbsp;&amp;nbsp; Range&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Range&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; date_Min&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Min&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; date_Max&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Max&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 86&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 31046&amp;nbsp;&amp;nbsp;&amp;nbsp; 2682374400&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; -10957&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; -946684800&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 20089&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1735689600&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 19 Feb 2015 03:57:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-check-if-the-var-is-date-or-datetime/m-p/174260#M264540</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2015-02-19T03:57:48Z</dc:date>
    </item>
    <item>
      <title>Re: how to check if the var is date or datetime</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-check-if-the-var-is-date-or-datetime/m-p/174261#M264541</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Tom: &lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;The only range of datetimes that could be a problem, I think, would be Jan 1, 1960 between midnight and 6am.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If the OP is certain that such a value can't exist in their data, then&lt;/P&gt;&lt;P&gt;if abs(datetime) gt 21600&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;would work for all dates through 2019&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 19 Feb 2015 05:24:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-check-if-the-var-is-date-or-datetime/m-p/174261#M264541</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2015-02-19T05:24:07Z</dc:date>
    </item>
    <item>
      <title>Re: how to check if the var is date or datetime</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-check-if-the-var-is-date-or-datetime/m-p/174262#M264542</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I would agree with Tom here.&amp;nbsp; How are you dealing with data if you don't know what format the data is in?&amp;nbsp; Know your underlying data and the coding becomes far easier, i.e. you wouldn't need a macro or complicated branching code.&amp;nbsp; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 19 Feb 2015 09:06:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-check-if-the-var-is-date-or-datetime/m-p/174262#M264542</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2015-02-19T09:06:04Z</dc:date>
    </item>
    <item>
      <title>Re: how to check if the var is date or datetime</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-check-if-the-var-is-date-or-datetime/m-p/174263#M264543</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I see those date time variables all the time.&amp;nbsp; They may have actual time-part or often the time is 00:00;00 but they &lt;SPAN style="text-decoration: underline;"&gt;always have the proper format&lt;/SPAN&gt; associated and that can be exploited by ANYDTDTE informat.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;DIV style="font-family: Courier New; font-size: 11pt;"&gt;&lt;STRONG style="color: #000080; background-color: #ffffff;"&gt;data&lt;/STRONG&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt; date(&lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; background-color: #ffffff;"&gt;keep&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;=date1 &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; background-color: #ffffff;"&gt;rename&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;=date1=date) datetime(&lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; background-color: #ffffff;"&gt;keep&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;=date2 &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; background-color: #ffffff;"&gt;rename&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;=date2=date);&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; background-color: #ffffff;"&gt;input&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt; date1 &lt;/SPAN&gt;&lt;SPAN style="color: #008080; background-color: #ffffff;"&gt;date9.&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt; @&lt;/SPAN&gt;&lt;STRONG style="color: #008080; background-color: #ffffff;"&gt;1&lt;/STRONG&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt; date2 &lt;/SPAN&gt;&lt;SPAN style="color: #008080; background-color: #ffffff;"&gt;datetime22.3&lt;/SPAN&gt;; &lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; background-color: #ffffff;"&gt;format&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt; date1 &lt;/SPAN&gt;&lt;SPAN style="color: #008080; background-color: #ffffff;"&gt;mmddyyd10.&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt; date2 &lt;/SPAN&gt;&lt;SPAN style="color: #008080; background-color: #ffffff;"&gt;datetime.&lt;/SPAN&gt;; &lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; background-color: #ffffff;"&gt;cards&lt;/SPAN&gt;; &lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffc0;"&gt;10JAN2013:00:00:00.000&lt;BR /&gt;22JAN2013:00:00:00.000&lt;BR /&gt;18DEC2012:00:00:00.000&lt;BR /&gt;30OCT2012:00:00:00.000&lt;BR /&gt;29NOV2012:00:00:00.000&lt;BR /&gt;17APR2014:11:37:45.157&lt;BR /&gt;17APR2014:13:28:45.887&lt;BR /&gt;17APR2014:11:37:45.157&lt;BR /&gt;25APR2014:18:41:42.090&lt;BR /&gt;17APR2014:13:28:45.887&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;;;;;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;STRONG style="color: #000080; background-color: #ffffff;"&gt;run&lt;/STRONG&gt;; &lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;STRONG style="color: #000080; background-color: #ffffff;"&gt;proc&lt;/STRONG&gt; &lt;STRONG style="color: #000080; background-color: #ffffff;"&gt;print&lt;/STRONG&gt; &lt;SPAN style="color: #0000ff; background-color: #ffffff;"&gt;data&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;=date;&lt;BR /&gt;&lt;/SPAN&gt;&lt;STRONG style="color: #000080; background-color: #ffffff;"&gt;proc&lt;/STRONG&gt; &lt;STRONG style="color: #000080; background-color: #ffffff;"&gt;print&lt;/STRONG&gt; &lt;SPAN style="color: #0000ff; background-color: #ffffff;"&gt;data&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;=datetime;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;STRONG style="color: #000080; background-color: #ffffff;"&gt;run&lt;/STRONG&gt;; &lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;STRONG style="color: #000080; background-color: #ffffff;"&gt;%macro&lt;/STRONG&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt; main(data=)&lt;/SPAN&gt;; &lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; data new;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; length dsname $&lt;/SPAN&gt;&lt;STRONG style="color: #008080; background-color: #ffffff;"&gt;41&lt;/STRONG&gt;; &lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; set &amp;amp;data indsname=indsname;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; dsname = indsname;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; new = input(vvalue(date),&lt;/SPAN&gt;&lt;SPAN style="color: #008080; background-color: #ffffff;"&gt;anydtdte22.&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;);&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; format new &lt;/SPAN&gt;&lt;SPAN style="color: #008080; background-color: #ffffff;"&gt;date9.&lt;/SPAN&gt;; &lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; run;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; proc print;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; run;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;STRONG style="color: #000080; background-color: #ffffff;"&gt;%mend&lt;/STRONG&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt; main;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;%&lt;/SPAN&gt;&lt;STRONG&gt;&lt;EM style="color: #000000; background-color: #ffffff;"&gt;main&lt;/EM&gt;&lt;/STRONG&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;(data=date);&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;%&lt;/SPAN&gt;&lt;STRONG&gt;&lt;EM style="color: #000000; background-color: #ffffff;"&gt;main&lt;/EM&gt;&lt;/STRONG&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;(data=datetime);&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV style="font-family: Courier New; font-size: 11pt;"&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV style="font-family: Courier New; font-size: 11pt;"&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&lt;IMG alt="2-19-2015 6-22-38 AM.png" class="jive-image" src="https://communities.sas.com/legacyfs/online/9226_2-19-2015 6-22-38 AM.png" /&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 19 Feb 2015 12:26:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-check-if-the-var-is-date-or-datetime/m-p/174263#M264543</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2015-02-19T12:26:42Z</dc:date>
    </item>
    <item>
      <title>Re: how to check if the var is date or datetime</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-check-if-the-var-is-date-or-datetime/m-p/174264#M264544</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Wow, &lt;A __default_attr="468858" __jive_macro_name="user" class="jive_macro jive_macro_user" href="https://communities.sas.com/"&gt;&lt;/A&gt; that is a very impressive solution (as usual)! I'm going to have to steal this.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 19 Feb 2015 13:52:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-check-if-the-var-is-date-or-datetime/m-p/174264#M264544</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2015-02-19T13:52:30Z</dc:date>
    </item>
    <item>
      <title>Re: how to check if the var is date or datetime</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-check-if-the-var-is-date-or-datetime/m-p/174265#M264545</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I second @PaigeMiller, first time saw VVALUE alive! It is fortunate that knowledge can sustain unlimited stealing &lt;img id="smileyhappy" class="emoticon emoticon-smileyhappy" src="https://communities.sas.com/i/smilies/16x16_smiley-happy.png" alt="Smiley Happy" title="Smiley Happy" /&gt;. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 19 Feb 2015 14:37:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-check-if-the-var-is-date-or-datetime/m-p/174265#M264545</guid>
      <dc:creator>Haikuo</dc:creator>
      <dc:date>2015-02-19T14:37:14Z</dc:date>
    </item>
    <item>
      <title>Re: how to check if the var is date or datetime</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-check-if-the-var-is-date-or-datetime/m-p/174266#M264546</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If date and datetime variables always have a correct format associated with them, couldn't the OP simply take advantage of exploiting the vvalue function? e.g., simply using something like 'if length(vvalue(date1)) gt 10' to identify datetime values?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 19 Feb 2015 17:58:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-check-if-the-var-is-date-or-datetime/m-p/174266#M264546</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2015-02-19T17:58:36Z</dc:date>
    </item>
    <item>
      <title>Re: how to check if the var is date or datetime</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-check-if-the-var-is-date-or-datetime/m-p/174267#M264547</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If you want to use the formats, function vformat() would be the best way to do it. Something like (this is incomplete) :&lt;/P&gt;&lt;PRE&gt;&lt;SPAN style="color: navy; font-size: 10.0pt; font-family: 'Courier New';"&gt;&lt;STRONG&gt;data&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black;"&gt; T1;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black;"&gt;&amp;nbsp; V=today();&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue;"&gt;output&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black;"&gt;;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black;"&gt;&amp;nbsp; V=datetime();&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue;"&gt;output&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black;"&gt;;&lt;/SPAN&gt;&lt;BR /&gt;&amp;nbsp; &lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue;"&gt;format&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black;"&gt; V &lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: teal;"&gt;datetime.&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black;"&gt;;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="color: navy; font-size: 10.0pt; font-family: 'Courier New';"&gt;&lt;STRONG&gt;data&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black;"&gt; T2;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue;"&gt;&amp;nbsp; set&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black;"&gt; T1; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black;"&gt;&amp;nbsp; F=vformat(V);&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black;"&gt;&amp;nbsp; X= ifn( F =: &lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: purple;"&gt;'DATETIME'&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black;"&gt; or find(F,&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: purple;"&gt;'DT'&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black;"&gt;)&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; , datepart(V)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ,ifn( F in: (&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: purple;"&gt;'YYMM'&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black;"&gt;,&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: purple;"&gt;'DDMM'&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black;"&gt;,&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: purple;"&gt;'MMDD'&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black;"&gt;,&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: purple;"&gt;'DATE'&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black;"&gt;)&amp;nbsp; , V&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ,ifn( V &amp;lt; &lt;/SPAN&gt;&lt;SPAN style="color: teal; font-size: 10.0pt; font-family: 'Courier New';"&gt;&lt;STRONG&gt;25000&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; , V&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ,&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; datepart(V) )));&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue;"&gt;&amp;nbsp; putlog&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black;"&gt; X X &lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: teal;"&gt;date.&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black;"&gt;;&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue;"&gt;&lt;BR /&gt;run&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black;"&gt;;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;P&gt;but using the formatted value directly and leveraging the &lt;SPAN style="color: #008080; background-color: #ffffff;"&gt;anydtdte. &lt;/SPAN&gt;informat as shown by &lt;A _jive_internal="true" href="https://communities.sas.com/people/data_null_;"&gt;data _null_&lt;/A&gt; is the most elegant way.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 19 Feb 2015 20:59:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-check-if-the-var-is-date-or-datetime/m-p/174267#M264547</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2015-02-19T20:59:54Z</dc:date>
    </item>
    <item>
      <title>Re: how to check if the var is date or datetime</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-check-if-the-var-is-date-or-datetime/m-p/174268#M264548</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Swimmer, don't forget to acknowledge the helpful answer(s).&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 26 Feb 2015 09:25:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-check-if-the-var-is-date-or-datetime/m-p/174268#M264548</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2015-02-26T09:25:00Z</dc:date>
    </item>
    <item>
      <title>Re: how to check if the var is date or datetime</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-check-if-the-var-is-date-or-datetime/m-p/174269#M264549</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you all! You guys are amazing!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 26 Feb 2015 17:33:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-check-if-the-var-is-date-or-datetime/m-p/174269#M264549</guid>
      <dc:creator>swimmer</dc:creator>
      <dc:date>2015-02-26T17:33:17Z</dc:date>
    </item>
  </channel>
</rss>

