<?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: DateTime Macro Variable in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/DateTime-Macro-Variable/m-p/688461#M209141</link>
    <description>&lt;P&gt;Thank you!&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 02 Oct 2020 10:06:56 GMT</pubDate>
    <dc:creator>twenty7</dc:creator>
    <dc:date>2020-10-02T10:06:56Z</dc:date>
    <item>
      <title>DateTime Macro Variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/DateTime-Macro-Variable/m-p/688446#M209131</link>
      <description>&lt;P&gt;I have a dataset which contains date in the following format 'DDMMMCCYY:00:00:00' (01SEP2020:00:00:00). The time part of the field is always ':00:00:00' as there is a separate field with the time.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to create a macro variable to be able automatically work out the previous days date as this code is due to be scheduled&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I would have expected to have been able to get to this using the format DATETIME.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;data _null_;
call symput('YTDAY',put(today()-1,datetime.));
run;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;This gives me the following '01JAN60:06:09:49' which I was not expecting.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Help?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Fri, 02 Oct 2020 08:35:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/DateTime-Macro-Variable/m-p/688446#M209131</guid>
      <dc:creator>twenty7</dc:creator>
      <dc:date>2020-10-02T08:35:19Z</dc:date>
    </item>
    <item>
      <title>Re: DateTime Macro Variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/DateTime-Macro-Variable/m-p/688449#M209133</link>
      <description>&lt;P&gt;TODAY() results in a&amp;nbsp;&lt;EM&gt;date&lt;/EM&gt; value, which is a count of &lt;EM&gt;days;&lt;/EM&gt;&amp;nbsp;&lt;EM&gt;datetimes&lt;/EM&gt; are counts of&amp;nbsp;&lt;EM&gt;seconds&lt;/EM&gt;.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Do not use a format for your macro variable, store the raw value. Unless you need the macro variable for display instead of calculation/comparison.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For more detailed help, please show the intended use of the macro variable.&lt;/P&gt;</description>
      <pubDate>Fri, 02 Oct 2020 09:27:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/DateTime-Macro-Variable/m-p/688449#M209133</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-10-02T09:27:47Z</dc:date>
    </item>
    <item>
      <title>Re: DateTime Macro Variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/DateTime-Macro-Variable/m-p/688450#M209134</link>
      <description>&lt;P&gt;With today you are getting number of days since 01-JAN-1960 when you are reading the result as input of Datetime (number of seconds since 01-JAN-1960 00:00:00) you are getting correct result, maybe not what you are expecting.&lt;/P&gt;</description>
      <pubDate>Fri, 02 Oct 2020 09:32:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/DateTime-Macro-Variable/m-p/688450#M209134</guid>
      <dc:creator>Aku</dc:creator>
      <dc:date>2020-10-02T09:32:05Z</dc:date>
    </item>
    <item>
      <title>Re: DateTime Macro Variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/DateTime-Macro-Variable/m-p/688451#M209135</link>
      <description>&lt;P&gt;Thanks KurtBremser.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am using the macro variable in a where statement to ensure I only extract the previous days records.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;where APP_DATE = '01SEP2020:00:00:00'DT;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;is what I am currently using but the intention was to replace this with the macro variable&lt;/P&gt;</description>
      <pubDate>Fri, 02 Oct 2020 09:35:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/DateTime-Macro-Variable/m-p/688451#M209135</guid>
      <dc:creator>twenty7</dc:creator>
      <dc:date>2020-10-02T09:35:25Z</dc:date>
    </item>
    <item>
      <title>Re: DateTime Macro Variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/DateTime-Macro-Variable/m-p/688455#M209137</link>
      <description>&lt;P&gt;Start with working non-macro code that uses the TODAY function:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;where datepart(APP_DATE) = today() - 1;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The DATEPART extracts the date from a datetime value.&lt;/P&gt;
&lt;P&gt;Then, use a macro variable:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let yesterday = %eval(%sysfunc(today()) - 1);

/* later in the code */
where datepart(APP_DATE) = &amp;amp;yesterday.;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 02 Oct 2020 09:44:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/DateTime-Macro-Variable/m-p/688455#M209137</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-10-02T09:44:19Z</dc:date>
    </item>
    <item>
      <title>Re: DateTime Macro Variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/DateTime-Macro-Variable/m-p/688461#M209141</link>
      <description>&lt;P&gt;Thank you!&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 02 Oct 2020 10:06:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/DateTime-Macro-Variable/m-p/688461#M209141</guid>
      <dc:creator>twenty7</dc:creator>
      <dc:date>2020-10-02T10:06:56Z</dc:date>
    </item>
  </channel>
</rss>

