<?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: Force Today() to a specific date? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Force-Today-to-a-specific-date/m-p/742136#M232073</link>
    <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/382392"&gt;@Rachie&lt;/a&gt;&amp;nbsp;&lt;BR /&gt;As you are running a batch process you can pass a date as a parameter if you want to use a&amp;nbsp; date other today. . For example&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Yourpath_to_sas/SAS.EXE -SYSPARM "01JAN2012"&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Now in the code you can have something like this&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%if &amp;amp;sysparam=' ' %then %do;
%let Run_Date          = %sysfunc(today(), date9.);
%end;
%else %do
%let Run_Date          = "&amp;amp;sysparam"d;
%end;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Tue, 18 May 2021 13:26:44 GMT</pubDate>
    <dc:creator>Sajid01</dc:creator>
    <dc:date>2021-05-18T13:26:44Z</dc:date>
    <item>
      <title>Force Today() to a specific date?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Force-Today-to-a-specific-date/m-p/742057#M232040</link>
      <description>&lt;P&gt;Hi there&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a batch job that I need to re-run which uses the Today() function throughout the code. I appreciate that I can go and change these references and also for future use adapt the program so the Today() is used once at the start of the program to create a macro variable that is referenced in the rest of the code.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;However, is it also possible to force the Today() to be a specific date value within a SAS session instead of defaulting to todays date?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 18 May 2021 04:18:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Force-Today-to-a-specific-date/m-p/742057#M232040</guid>
      <dc:creator>Rachie</dc:creator>
      <dc:date>2021-05-18T04:18:28Z</dc:date>
    </item>
    <item>
      <title>Re: Force Today() to a specific date?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Force-Today-to-a-specific-date/m-p/742058#M232041</link>
      <description>&lt;P&gt;If you want a specific date then you wouldn't use the TODAY function at all.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;A good approach is to assign the program run date to a macro variable like so:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;*%let Run_Date         = 18May2021;
%let Run_Date          = %sysfunc(today(), date9.);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Then use the macro variable throughout your code. If you want a specific date then uncomment the specific date assignment and comment the TODAY statement.&lt;/P&gt;
&lt;P&gt;If you are running a batch job then you can pass in the required date in as a job parameter and avoid any coding changes. How you do that would depend on how you are scheduling the job.&lt;/P&gt;</description>
      <pubDate>Tue, 18 May 2021 04:30:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Force-Today-to-a-specific-date/m-p/742058#M232041</guid>
      <dc:creator>SASKiwi</dc:creator>
      <dc:date>2021-05-18T04:30:06Z</dc:date>
    </item>
    <item>
      <title>Re: Force Today() to a specific date?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Force-Today-to-a-specific-date/m-p/742061#M232044</link>
      <description>TODAY() works from the system clock. Changing that would have grave consequences.&lt;BR /&gt;Change the calls to macro variables.</description>
      <pubDate>Tue, 18 May 2021 05:34:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Force-Today-to-a-specific-date/m-p/742061#M232044</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2021-05-18T05:34:21Z</dc:date>
    </item>
    <item>
      <title>Re: Force Today() to a specific date?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Force-Today-to-a-specific-date/m-p/742101#M232056</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/382392"&gt;@Rachie&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;However, is it also possible to force the Today() to be a specific date value within a SAS session instead of defaulting to todays date?&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Is this what you want?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let today = %sysevalf('01MAY2021'd);
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 18 May 2021 10:50:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Force-Today-to-a-specific-date/m-p/742101#M232056</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2021-05-18T10:50:06Z</dc:date>
    </item>
    <item>
      <title>Re: Force Today() to a specific date?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Force-Today-to-a-specific-date/m-p/742136#M232073</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/382392"&gt;@Rachie&lt;/a&gt;&amp;nbsp;&lt;BR /&gt;As you are running a batch process you can pass a date as a parameter if you want to use a&amp;nbsp; date other today. . For example&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Yourpath_to_sas/SAS.EXE -SYSPARM "01JAN2012"&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Now in the code you can have something like this&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%if &amp;amp;sysparam=' ' %then %do;
%let Run_Date          = %sysfunc(today(), date9.);
%end;
%else %do
%let Run_Date          = "&amp;amp;sysparam"d;
%end;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 18 May 2021 13:26:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Force-Today-to-a-specific-date/m-p/742136#M232073</guid>
      <dc:creator>Sajid01</dc:creator>
      <dc:date>2021-05-18T13:26:44Z</dc:date>
    </item>
    <item>
      <title>Re: Force Today() to a specific date?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Force-Today-to-a-specific-date/m-p/742154#M232074</link>
      <description>&lt;P&gt;Something like this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let override_date = %sysfunc(mdy(1, 1, 2021));
%let today = %sysfunc(coalescec(&amp;amp;override_date., %sysfunc(today())));

%put &amp;amp;today;

%let override_date =;
%let today = %sysfunc(coalescec(&amp;amp;override_date., %sysfunc(today())));
%put &amp;amp;today;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/382392"&gt;@Rachie&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hi there&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have a batch job that I need to re-run which uses the Today() function throughout the code. I appreciate that I can go and change these references and also for future use adapt the program so the Today() is used once at the start of the program to create a macro variable that is referenced in the rest of the code.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;However, is it also possible to force the Today() to be a specific date value within a SAS session instead of defaulting to todays date?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 18 May 2021 13:43:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Force-Today-to-a-specific-date/m-p/742154#M232074</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2021-05-18T13:43:27Z</dc:date>
    </item>
  </channel>
</rss>

