<?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 yesterday function not working in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/yesterday-function-not-working/m-p/863445#M38146</link>
    <description>&lt;P&gt;Hi there&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am trying to get yesterdays records from a dataset. It works perfectly in SAS however after creating a job on SAS management console, I see it did not produce any records.&lt;/P&gt;
&lt;P&gt;When I run it in SAS it produces 4000 records, however when it runs on SAS management console as a process, it produces 0 records.&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;proc sql;
create table yestrdayrecords as 
select * from getDate
where date1 = intnx('day',today(),-1)
;quit;&lt;/PRE&gt;</description>
    <pubDate>Fri, 10 Mar 2023 14:09:35 GMT</pubDate>
    <dc:creator>Citrine10</dc:creator>
    <dc:date>2023-03-10T14:09:35Z</dc:date>
    <item>
      <title>yesterday function not working</title>
      <link>https://communities.sas.com/t5/New-SAS-User/yesterday-function-not-working/m-p/863445#M38146</link>
      <description>&lt;P&gt;Hi there&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am trying to get yesterdays records from a dataset. It works perfectly in SAS however after creating a job on SAS management console, I see it did not produce any records.&lt;/P&gt;
&lt;P&gt;When I run it in SAS it produces 4000 records, however when it runs on SAS management console as a process, it produces 0 records.&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;proc sql;
create table yestrdayrecords as 
select * from getDate
where date1 = intnx('day',today(),-1)
;quit;&lt;/PRE&gt;</description>
      <pubDate>Fri, 10 Mar 2023 14:09:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/yesterday-function-not-working/m-p/863445#M38146</guid>
      <dc:creator>Citrine10</dc:creator>
      <dc:date>2023-03-10T14:09:35Z</dc:date>
    </item>
    <item>
      <title>Re: yesterday function not working</title>
      <link>https://communities.sas.com/t5/New-SAS-User/yesterday-function-not-working/m-p/863452#M38147</link>
      <description>&lt;P&gt;First, carefully check the log from your job and make sure there are no bad notes/warnings/errors before this in the log.&amp;nbsp; If SAS hits an error in a job, it can sent system option obs=0 which will result in 0 obs being processed.&amp;nbsp; There will be a note about this in the log.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You may also want to check that the system date on the server running the job is set correctly, by adding code like:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_ ;
  x=today() ;
  put x date9. ;
run ;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Before the query.&lt;/P&gt;</description>
      <pubDate>Fri, 10 Mar 2023 14:30:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/yesterday-function-not-working/m-p/863452#M38147</guid>
      <dc:creator>Quentin</dc:creator>
      <dc:date>2023-03-10T14:30:32Z</dc:date>
    </item>
    <item>
      <title>Re: yesterday function not working</title>
      <link>https://communities.sas.com/t5/New-SAS-User/yesterday-function-not-working/m-p/863461#M38148</link>
      <description>&lt;P&gt;The source dataset is a temporary dataset in WORK, so it is local to the process. Work through the log to see where and how it is created, it's probably empty.&lt;/P&gt;</description>
      <pubDate>Fri, 10 Mar 2023 15:08:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/yesterday-function-not-working/m-p/863461#M38148</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2023-03-10T15:08:29Z</dc:date>
    </item>
    <item>
      <title>Re: yesterday function not working</title>
      <link>https://communities.sas.com/t5/New-SAS-User/yesterday-function-not-working/m-p/866685#M38325</link>
      <description>Correct, it is a local dataset created in the work library. Is this why it is storing zero records? How do I prevent this?</description>
      <pubDate>Tue, 28 Mar 2023 07:55:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/yesterday-function-not-working/m-p/866685#M38325</guid>
      <dc:creator>Citrine10</dc:creator>
      <dc:date>2023-03-28T07:55:50Z</dc:date>
    </item>
    <item>
      <title>Re: yesterday function not working</title>
      <link>https://communities.sas.com/t5/New-SAS-User/yesterday-function-not-working/m-p/866687#M38326</link>
      <description>&lt;P&gt;Inspect the log to see where and how&lt;/P&gt;
&lt;PRE&gt;getDate&lt;/PRE&gt;
&lt;P&gt;is created. Then work back from there (if needed) until you find where the batch process behaves differently than your interactive submit.&lt;/P&gt;</description>
      <pubDate>Tue, 28 Mar 2023 08:03:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/yesterday-function-not-working/m-p/866687#M38326</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2023-03-28T08:03:13Z</dc:date>
    </item>
    <item>
      <title>Re: yesterday function not working</title>
      <link>https://communities.sas.com/t5/New-SAS-User/yesterday-function-not-working/m-p/866688#M38327</link>
      <description>&lt;P&gt;This is how getDate is created:&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;data getDate;&lt;BR /&gt;set mydata.sampleset;&lt;BR /&gt;date1 = datepart(loaddate);&lt;BR /&gt;format date1 date9.;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 28 Mar 2023 08:06:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/yesterday-function-not-working/m-p/866688#M38327</guid>
      <dc:creator>Citrine10</dc:creator>
      <dc:date>2023-03-28T08:06:27Z</dc:date>
    </item>
    <item>
      <title>Re: yesterday function not working</title>
      <link>https://communities.sas.com/t5/New-SAS-User/yesterday-function-not-working/m-p/866691#M38328</link>
      <description>&lt;P&gt;Don't post the code. Post the&amp;nbsp;&lt;U&gt;log&lt;/U&gt; by copy/pasting the whole text (code and messages) of the step into a code box(&amp;lt;/&amp;gt;)..&lt;/P&gt;
&lt;P&gt;For comparison, also post the log from your successful manual execution.&lt;/P&gt;</description>
      <pubDate>Tue, 28 Mar 2023 08:17:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/yesterday-function-not-working/m-p/866691#M38328</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2023-03-28T08:17:19Z</dc:date>
    </item>
    <item>
      <title>Re: yesterday function not working</title>
      <link>https://communities.sas.com/t5/New-SAS-User/yesterday-function-not-working/m-p/866918#M38339</link>
      <description>&lt;P&gt;hi, so I see SAS generates macro date variables and the one I need to use is&amp;nbsp;TODAY1_DATE9. I have converted my variable date1 from date to string to see if that will work when I do the where clause however it is still not working:&lt;/P&gt;
&lt;PRE&gt;data getDate;
set mydata.sampleset;
date1 = datepart(loaddate);
format date1 date9.;
char_date = put(date1,date9.);
run;

%let mydate = &amp;amp;TODAY1_DATE9.;

proc sql;
create table oldrecs as 
select * from getDate
where char_date = &amp;amp;TODAY1_DATE9.;
;quit;&lt;/PRE&gt;
&lt;P&gt;Log:&lt;/P&gt;
&lt;PRE&gt;29         proc sql;
30         create table oldrecs as
31         select * from getDate
32         where char_date = &amp;amp;TODAY1_DATE9.;
NOTE: PROC SQL set option NOEXEC and will continue to check the syntax of statements.
NOTE: Line generated by the macro variable "TODAY1_DATE9".
32          27MAR2023
              _______
              22
              76
ERROR 22-322: Syntax error, expecting one of the following: !, !!, &amp;amp;, *, **, +, -, /, &amp;lt;, &amp;lt;=, &amp;lt;&amp;gt;, =, &amp;gt;, &amp;gt;=, AND, EQ, EQT, GE, GET, 
              GROUP, GT, GTT, HAVING, LE, LET, LT, LTT, NE, NET, OR, ORDER, ^=, |, ||, ~=.  

ERROR 76-322: Syntax error, statement will be ignored.

33         ;quit;&lt;/PRE&gt;
&lt;P&gt;Any idea on how to resolve this by using the date macro variables?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 29 Mar 2023 07:21:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/yesterday-function-not-working/m-p/866918#M38339</guid>
      <dc:creator>Citrine10</dc:creator>
      <dc:date>2023-03-29T07:21:55Z</dc:date>
    </item>
    <item>
      <title>Re: yesterday function not working</title>
      <link>https://communities.sas.com/t5/New-SAS-User/yesterday-function-not-working/m-p/866921#M38341</link>
      <description>&lt;P&gt;Please show the code where the macro variable (today1) is created.&lt;/P&gt;
&lt;P&gt;The way you use it, it should contain the raw, unformatted date value (count of days since 1960-01-01). See Maxim 28: Macro Variables Need No Formats.&lt;/P&gt;</description>
      <pubDate>Wed, 29 Mar 2023 07:31:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/yesterday-function-not-working/m-p/866921#M38341</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2023-03-29T07:31:02Z</dc:date>
    </item>
    <item>
      <title>Re: yesterday function not working</title>
      <link>https://communities.sas.com/t5/New-SAS-User/yesterday-function-not-working/m-p/866925#M38342</link>
      <description>&lt;P&gt;I do not create today1. It is automatically created when running any sas program. it is the built in sas macro variables that gets generated.&amp;nbsp;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="today1.PNG" style="width: 581px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/82142i944C85CD6DAA70BA/image-size/large?v=v2&amp;amp;px=999" role="button" title="today1.PNG" alt="today1.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 29 Mar 2023 07:53:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/yesterday-function-not-working/m-p/866925#M38342</guid>
      <dc:creator>Citrine10</dc:creator>
      <dc:date>2023-03-29T07:53:21Z</dc:date>
    </item>
    <item>
      <title>Re: yesterday function not working</title>
      <link>https://communities.sas.com/t5/New-SAS-User/yesterday-function-not-working/m-p/866930#M38344</link>
      <description>&lt;P&gt;There should be (from the systematics) a variable&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;TODAY1_SASDATE&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;in this list. Use this in your program.&lt;/P&gt;</description>
      <pubDate>Wed, 29 Mar 2023 09:00:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/yesterday-function-not-working/m-p/866930#M38344</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2023-03-29T09:00:26Z</dc:date>
    </item>
    <item>
      <title>Re: yesterday function not working</title>
      <link>https://communities.sas.com/t5/New-SAS-User/yesterday-function-not-working/m-p/866951#M38348</link>
      <description>&lt;P&gt;I'm surprised to see that long list of TodayXX macro variables.&amp;nbsp; Just curious, in that screenshot, what program / client are you showing? Is that from SAS Studio, Enterprise Guide, or SAS Management Console? If you scroll down, how many TodayXX variables do you have?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I'm hoping these macro variables were generated by some custom program / autoexec that runs on your server.&amp;nbsp;&amp;nbsp;I've seen SAS clients clutter the symbol table with global macro variables. But I'd hate to think that some developer in Cary thought it was a good idea to make hundreds of macro variables to store the current date (and prior dates) in various formats.&lt;/P&gt;</description>
      <pubDate>Wed, 29 Mar 2023 12:26:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/yesterday-function-not-working/m-p/866951#M38348</guid>
      <dc:creator>Quentin</dc:creator>
      <dc:date>2023-03-29T12:26:49Z</dc:date>
    </item>
    <item>
      <title>Re: yesterday function not working</title>
      <link>https://communities.sas.com/t5/New-SAS-User/yesterday-function-not-working/m-p/866976#M38349</link>
      <description>&lt;P&gt;From that log the value of the macro variable&amp;nbsp;TODAY1_DATE9 is the string&amp;nbsp;27MAR2023.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So your code generates this boolean expression in the WHERE condition:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;char_date = 27MAR2023&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Which is not valid SAS code since the thing after the equal sign is not a literal value or a variable reference or and expression.&amp;nbsp; &amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If CHAR_DATE is a character variable then you need to generate code like&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;char_date = "27MAR2023"&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;instead.&amp;nbsp; So just add the quotes around the reference to the macro variable in your code:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;char_date = "&amp;amp;TODAY1_DATE9."&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If you wanted to compare it to an actual date value you would also need to append the letter D.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;date1 = "&amp;amp;TODAY1_DATE9."d&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 29 Mar 2023 13:26:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/yesterday-function-not-working/m-p/866976#M38349</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2023-03-29T13:26:50Z</dc:date>
    </item>
  </channel>
</rss>

