<?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 DATES!!!! in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/DATES/m-p/367011#M87338</link>
    <description>&lt;P&gt;I will always and forever struggle with dates in SAS.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have a report that has a column called "Date of Last Review" - we'll call this DOLR for short. When I import this into SAS, it's brought in as, for example, 03MAR2017 - which is perfect.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have a Macro for DOLR - so that when the next report is run, when DOLR is "" that the DOLR should be what I enter in the for the Macro. I'm having huge issues with this simple task. SAS was importing DOLR as a numeric when I wanted it as a character. Tried to fix it, didn't work.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So I'll have it stay as a numeric. When I let my macro:&lt;/P&gt;
&lt;P&gt;%let DOLR=18/03/2017;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;my output for DOLR is&lt;/P&gt;
&lt;P&gt;01JAN1960&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What gives?? Why is SAS so insane when it comes to dates?? I've tried various iterations of 03Mar2017 in the let macro statement&amp;nbsp;and nothing comes even remotely close to the date.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Full code:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%let DOLR=18/03/2017;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;PROC IMPORT DATAFILE="/sp/ClinOps/send/Excel Files/Previous.xls"&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; OUT=PreviousIn&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; DBMS=XLS&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; REPLACE;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Sheet="Final_eTMF";&lt;BR /&gt;RUN;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;data PreviousOut (drop='Paper Received Date'n);&lt;BR /&gt;length CodeName $ 20;&lt;BR /&gt;set PreviousIn;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc sort data=PreviousOut;&lt;BR /&gt;by 'TMF Obj ID'n;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc sort data=Final;&lt;BR /&gt;by 'TMF Obj ID'n;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data mPrevious;&lt;BR /&gt;merge PreviousOut Final;&lt;/P&gt;
&lt;P&gt;by 'TMF Obj ID'n;&lt;BR /&gt;If Reviewed="" then Reviewed="n";&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data ToReview;&lt;BR /&gt;set mPrevious;&lt;BR /&gt;if Reviewed="y" and DOLR="" then DOLR=&amp;amp;DOLR;&lt;BR /&gt;drop X Y; &lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc sort data=ToReview;&lt;BR /&gt;by CodeName Zone Section Artifact;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc export data=ToReview&lt;BR /&gt;&amp;nbsp;outfile="/sp/ClinOps/send/Excel Files/To Review eTMF.xls"&lt;BR /&gt;&amp;nbsp;label dbms=xls replace;&lt;BR /&gt;run;&lt;/P&gt;</description>
    <pubDate>Wed, 14 Jun 2017 15:43:09 GMT</pubDate>
    <dc:creator>dereck255</dc:creator>
    <dc:date>2017-06-14T15:43:09Z</dc:date>
    <item>
      <title>DATES!!!!</title>
      <link>https://communities.sas.com/t5/SAS-Programming/DATES/m-p/367011#M87338</link>
      <description>&lt;P&gt;I will always and forever struggle with dates in SAS.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have a report that has a column called "Date of Last Review" - we'll call this DOLR for short. When I import this into SAS, it's brought in as, for example, 03MAR2017 - which is perfect.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have a Macro for DOLR - so that when the next report is run, when DOLR is "" that the DOLR should be what I enter in the for the Macro. I'm having huge issues with this simple task. SAS was importing DOLR as a numeric when I wanted it as a character. Tried to fix it, didn't work.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So I'll have it stay as a numeric. When I let my macro:&lt;/P&gt;
&lt;P&gt;%let DOLR=18/03/2017;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;my output for DOLR is&lt;/P&gt;
&lt;P&gt;01JAN1960&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What gives?? Why is SAS so insane when it comes to dates?? I've tried various iterations of 03Mar2017 in the let macro statement&amp;nbsp;and nothing comes even remotely close to the date.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Full code:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%let DOLR=18/03/2017;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;PROC IMPORT DATAFILE="/sp/ClinOps/send/Excel Files/Previous.xls"&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; OUT=PreviousIn&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; DBMS=XLS&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; REPLACE;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Sheet="Final_eTMF";&lt;BR /&gt;RUN;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;data PreviousOut (drop='Paper Received Date'n);&lt;BR /&gt;length CodeName $ 20;&lt;BR /&gt;set PreviousIn;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc sort data=PreviousOut;&lt;BR /&gt;by 'TMF Obj ID'n;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc sort data=Final;&lt;BR /&gt;by 'TMF Obj ID'n;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data mPrevious;&lt;BR /&gt;merge PreviousOut Final;&lt;/P&gt;
&lt;P&gt;by 'TMF Obj ID'n;&lt;BR /&gt;If Reviewed="" then Reviewed="n";&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data ToReview;&lt;BR /&gt;set mPrevious;&lt;BR /&gt;if Reviewed="y" and DOLR="" then DOLR=&amp;amp;DOLR;&lt;BR /&gt;drop X Y; &lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc sort data=ToReview;&lt;BR /&gt;by CodeName Zone Section Artifact;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc export data=ToReview&lt;BR /&gt;&amp;nbsp;outfile="/sp/ClinOps/send/Excel Files/To Review eTMF.xls"&lt;BR /&gt;&amp;nbsp;label dbms=xls replace;&lt;BR /&gt;run;&lt;/P&gt;</description>
      <pubDate>Wed, 14 Jun 2017 15:43:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/DATES/m-p/367011#M87338</guid>
      <dc:creator>dereck255</dc:creator>
      <dc:date>2017-06-14T15:43:09Z</dc:date>
    </item>
    <item>
      <title>Re: DATES!!!!</title>
      <link>https://communities.sas.com/t5/SAS-Programming/DATES/m-p/367014#M87339</link>
      <description>&lt;P&gt;This problem is only partly a matter of dates.&amp;nbsp; It's also a matter of understanding how macro language works.&amp;nbsp; Your code generates a statement along these lines:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;if .... then DOLR = 18/03/2017;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In a DATA step, that's just 18 divided by 3, divided by 2017.&amp;nbsp; The answer is close enough to zero, so you are getting the date that matches the number zero (which is January 1, 1960).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Within knowing what's in the data set FINAL ... it's coming in from unknown sources as far as I can see ... it's difficult to find a solution. It might be any of these (or even somthing slightly similar):&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%let DOLR = 18MAR2017;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%let DOLR = "18MAR2017"d;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But that should at least point you in the right direction.&lt;/P&gt;</description>
      <pubDate>Wed, 14 Jun 2017 15:51:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/DATES/m-p/367014#M87339</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2017-06-14T15:51:43Z</dc:date>
    </item>
    <item>
      <title>Re: DATES!!!!</title>
      <link>https://communities.sas.com/t5/SAS-Programming/DATES/m-p/367022#M87340</link>
      <description>To think that all I was missing this entire time was "d".....&lt;BR /&gt;&lt;BR /&gt;Thank you!!!</description>
      <pubDate>Wed, 14 Jun 2017 15:59:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/DATES/m-p/367022#M87340</guid>
      <dc:creator>dereck255</dc:creator>
      <dc:date>2017-06-14T15:59:48Z</dc:date>
    </item>
    <item>
      <title>Re: DATES!!!!</title>
      <link>https://communities.sas.com/t5/SAS-Programming/DATES/m-p/367055#M87351</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/16003"&gt;@dereck255&lt;/a&gt; wrote:&lt;BR /&gt;To think that all I was missing this entire time was "d".....&lt;BR /&gt;&lt;BR /&gt;Thank you!!!&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&lt;STRONG&gt;NO! &lt;/STRONG&gt;You need to do more than just add 'd'.&lt;/P&gt;
&lt;P&gt;Using&lt;/P&gt;
&lt;P&gt;%let DOLR='18/03/2017'd;&lt;/P&gt;
&lt;P&gt;WILL not work. The literal values when used by SAS must be in the form of ddMONyy or ddMONyyyy,&lt;/P&gt;
&lt;P&gt;One major reason is there are so many ways people use dates that 10/03/2017 could be 03&amp;nbsp;OCT&amp;nbsp; or 10 MAR with added confusion when no separator is included: 010203 could be 1 Feb 2003, 2 Jan 2003, 3 Feb 2001.&lt;/P&gt;</description>
      <pubDate>Wed, 14 Jun 2017 17:03:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/DATES/m-p/367055#M87351</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2017-06-14T17:03:32Z</dc:date>
    </item>
    <item>
      <title>Re: DATES!!!!</title>
      <link>https://communities.sas.com/t5/SAS-Programming/DATES/m-p/367059#M87354</link>
      <description>&lt;P&gt;Don't worry &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt; I already changed it to:"18MAR2017",d&lt;/P&gt;</description>
      <pubDate>Wed, 14 Jun 2017 17:09:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/DATES/m-p/367059#M87354</guid>
      <dc:creator>dereck255</dc:creator>
      <dc:date>2017-06-14T17:09:49Z</dc:date>
    </item>
    <item>
      <title>Re: DATES!!!!</title>
      <link>https://communities.sas.com/t5/SAS-Programming/DATES/m-p/367072#M87358</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/16003"&gt;@dereck255&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;Don't worry &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt; I already changed it to:"18MAR2017",d&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;We get a question, or an "it didn't work" to a suggestion when someone uses a '01/05/2015'd about twice a week or so.&lt;/P&gt;
&lt;P&gt;Often we have provided an example that shows&lt;BR /&gt;data junk;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; datevalue = '01MAR2017'd;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And then the OP comes back saying&lt;/P&gt;
&lt;P&gt;data junk;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; datevalue = '03/01/2017'd;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;has a missing value.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So I just thought I'd head that if in case of a misunderstanding.&lt;/P&gt;</description>
      <pubDate>Wed, 14 Jun 2017 17:35:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/DATES/m-p/367072#M87358</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2017-06-14T17:35:26Z</dc:date>
    </item>
  </channel>
</rss>

