<?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: If Statement - Dates in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/If-Statement-Dates/m-p/693176#M211327</link>
    <description>And I see that it should be the same. Howe4ver when I run the 2 queries. the query with the '20oct2020'd works and i get results. When I use &amp;amp;run_date_test, i get no results. Stumped&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;data _null_;&lt;BR /&gt;select (weekday(today()));&lt;BR /&gt;  when (3) run_date_test = today() - 3; /* Tuesday */&lt;BR /&gt;  when (4,5,6,7) run_date_test = today() - 1; /* Wednesday to Saturday */&lt;BR /&gt;  otherwise abort abend 5; /* Sunday, Monday */&lt;BR /&gt;end;&lt;BR /&gt;call symputx('run_date_test',run_date_test);&lt;BR /&gt;run;&lt;BR /&gt;&lt;BR /&gt;proc sql;&lt;BR /&gt;  select &amp;amp;run_date_test as date2,&lt;BR /&gt;  		 '20oct2020'd as date3&lt;BR /&gt;  from sashelp.class&lt;BR /&gt;  where name='Alfred';&lt;BR /&gt;quit;&lt;BR /&gt;&lt;BR /&gt;proc sql;&lt;BR /&gt;select * from PRD4.WLNSOTRX_EDWT (obs = 10)&lt;BR /&gt;where SOENTD = &amp;amp;run_date_test;&lt;BR /&gt;run;&lt;BR /&gt;&lt;BR /&gt;proc sql;&lt;BR /&gt;select * from PRD4.WLNSOTRX_EDWT (obs = 10)&lt;BR /&gt;where SOENTD = '20oct2020'd;&lt;BR /&gt;run;</description>
    <pubDate>Wed, 21 Oct 2020 13:38:33 GMT</pubDate>
    <dc:creator>Jyuen204</dc:creator>
    <dc:date>2020-10-21T13:38:33Z</dc:date>
    <item>
      <title>If Statement - Dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/If-Statement-Dates/m-p/692845#M211155</link>
      <description>&lt;P&gt;I have a piece of code where in need to validate a day of the week and use a certain date in the query.&lt;BR /&gt;If the today is tuesday I want to pull&amp;nbsp;&lt;STRONG&gt;RUN_DATE_MON_SAS&lt;/STRONG&gt; date. if day is wed, thur, fri, sat, i wan it to use&amp;nbsp;&lt;STRONG&gt;RUN_DATE_SAS.&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;Thank you!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Data DATES;&lt;BR /&gt;Format&amp;nbsp;RUN_DATE&lt;BR /&gt;EXP_DATE&lt;BR /&gt;date9.;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;P&gt;RUN_DATE = today()-1;&lt;BR /&gt;RUN_DATE_MON = today()-3;&lt;BR /&gt;EXP_DATE = today()+1;&lt;BR /&gt;RUN_DATE_SAS = "'" || put(run_date, date9.) || "'d";&lt;BR /&gt;RUN_DATE_MON_SAS = "'" || put(run_date_mon, date9.) || "'d";&lt;BR /&gt;&lt;BR /&gt;Call Symput('RUN_DATE',REPORT_DATE);&lt;/P&gt;
&lt;P&gt;Call Symput('EXP_DATE',EXP_DATE);&lt;BR /&gt;Call Symput('RUN_DATE_SAS',RUN_DATE_SAS);&lt;BR /&gt;Call Symput('RUN_DATE_MON_SAS',RUN_DATE_MON_SAS);&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc sql;&lt;BR /&gt;select * from TABLE1&lt;BR /&gt;&lt;STRONG&gt;&lt;FONT color="#FF0000"&gt;where A.SOENTD &amp;gt;= &amp;amp;RUN_DATE_MON_SAS;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;BR /&gt;run;&lt;/P&gt;</description>
      <pubDate>Tue, 20 Oct 2020 12:52:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/If-Statement-Dates/m-p/692845#M211155</guid>
      <dc:creator>Jyuen204</dc:creator>
      <dc:date>2020-10-20T12:52:38Z</dc:date>
    </item>
    <item>
      <title>Re: If Statement - Dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/If-Statement-Dates/m-p/692848#M211157</link>
      <description>&lt;P&gt;What about Sunday and Monday?&lt;/P&gt;</description>
      <pubDate>Tue, 20 Oct 2020 13:01:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/If-Statement-Dates/m-p/692848#M211157</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-10-20T13:01:34Z</dc:date>
    </item>
    <item>
      <title>Re: If Statement - Dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/If-Statement-Dates/m-p/692999#M211237</link>
      <description>For my purposes there is no data refreshed on those particular days.</description>
      <pubDate>Tue, 20 Oct 2020 20:05:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/If-Statement-Dates/m-p/692999#M211237</guid>
      <dc:creator>Jyuen204</dc:creator>
      <dc:date>2020-10-20T20:05:25Z</dc:date>
    </item>
    <item>
      <title>Re: If Statement - Dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/If-Statement-Dates/m-p/693021#M211250</link>
      <description>&lt;P&gt;You need to account for those days in your code, because, and I can promise you that, someday someone&amp;nbsp;&lt;EM&gt;will&lt;/EM&gt; run that program on a Sunday or Monday. The least you need to do is a program abort.&lt;/P&gt;</description>
      <pubDate>Tue, 20 Oct 2020 21:10:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/If-Statement-Dates/m-p/693021#M211250</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-10-20T21:10:52Z</dc:date>
    </item>
    <item>
      <title>Re: If Statement - Dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/If-Statement-Dates/m-p/693025#M211251</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
select (weekday(today()));
  when (3) run_date = today() - 3; /* Tuesday */
  when (4,5,6,7) run_date = today() - 1; /* Wednesday to Saturday */
  otherwise abort abend 5; /* Sunday, Monday */
end;
call symputx('run_date',run_date);
run;

proc sql;
select * from TABLE1
where A.SOENTD &amp;gt;= &amp;amp;run_date.;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 20 Oct 2020 21:22:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/If-Statement-Dates/m-p/693025#M211251</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-10-20T21:22:42Z</dc:date>
    </item>
    <item>
      <title>Re: If Statement - Dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/If-Statement-Dates/m-p/693069#M211273</link>
      <description>I need to format the RUN_DATE to a teradata format as I am using a passthrough. My apologies I forgot to include that. In my original code I had accounted for this in the coding using "'" || put(run_date, date9.) || "'d";&lt;BR /&gt;&lt;BR /&gt;would I just add this line within your Data section?&lt;BR /&gt;RUN_DATE = "'" || put(run_date, date9.) || "'d";</description>
      <pubDate>Wed, 21 Oct 2020 04:49:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/If-Statement-Dates/m-p/693069#M211273</guid>
      <dc:creator>Jyuen204</dc:creator>
      <dc:date>2020-10-21T04:49:43Z</dc:date>
    </item>
    <item>
      <title>Re: If Statement - Dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/If-Statement-Dates/m-p/693080#M211280</link>
      <description>&lt;P&gt;Database systems usually need a YYYY-MM-DD format for date literals. The only system I know that uses the DATE9 is SAS.&lt;/P&gt;
&lt;P&gt;See&amp;nbsp;&lt;A href="https://docs.teradata.com/reader/S0Fw2AVH8ff3MDA0wDOHlQ/zzj0~rymqnV6H24CtsCiOw" target="_blank" rel="noopener"&gt;https://docs.teradata.com/reader/S0Fw2AVH8ff3MDA0wDOHlQ/zzj0~rymqnV6H24CtsCiOw&lt;/A&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 21 Oct 2020 06:40:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/If-Statement-Dates/m-p/693080#M211280</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-10-21T06:40:25Z</dc:date>
    </item>
    <item>
      <title>Re: If Statement - Dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/If-Statement-Dates/m-p/693110#M211297</link>
      <description>Querying Via a Teradata passthrough al I need to format the date a bit differently&lt;BR /&gt;</description>
      <pubDate>Wed, 21 Oct 2020 11:40:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/If-Statement-Dates/m-p/693110#M211297</guid>
      <dc:creator>Jyuen204</dc:creator>
      <dc:date>2020-10-21T11:40:05Z</dc:date>
    </item>
    <item>
      <title>Re: If Statement - Dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/If-Statement-Dates/m-p/693111#M211298</link>
      <description>&lt;P&gt;Well, let's start with the usual:&lt;/P&gt;
&lt;P&gt;how does a successful pass-through with a non-macro literal date look?&lt;/P&gt;
&lt;P&gt;From that, macro coding can be developed.&lt;/P&gt;</description>
      <pubDate>Wed, 21 Oct 2020 11:43:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/If-Statement-Dates/m-p/693111#M211298</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-10-21T11:43:49Z</dc:date>
    </item>
    <item>
      <title>Re: If Statement - Dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/If-Statement-Dates/m-p/693117#M211301</link>
      <description>My bad, I am querying an Oracle db.&lt;BR /&gt;&lt;BR /&gt;Select * from TABLE&lt;BR /&gt;where SOENTD &amp;gt;= '17Oct2020'd&lt;BR /&gt;&lt;BR /&gt;that is if I was using a hardcoded date. &lt;BR /&gt;Otherwise I'm currently using this to define the dates&lt;BR /&gt;&lt;BR /&gt;RUN_DATE = today()-1;&lt;BR /&gt;RUN_DATE_MON = today()-3;&lt;BR /&gt;RUN_DATE_SAS = "'" || put(run_date, date9.) || "'d";&lt;BR /&gt;RUN_DATE_MON_SAS = "'" || put(run_date_mon, date9.) || "'d";</description>
      <pubDate>Wed, 21 Oct 2020 11:59:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/If-Statement-Dates/m-p/693117#M211301</guid>
      <dc:creator>Jyuen204</dc:creator>
      <dc:date>2020-10-21T11:59:10Z</dc:date>
    </item>
    <item>
      <title>Re: If Statement - Dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/If-Statement-Dates/m-p/693134#M211311</link>
      <description>&lt;P&gt;This&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Select * from TABLE
where SOENTD &amp;gt;= '17Oct2020'd&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;looks like pure SAS code to me, in Oracle passthrough you would need to use the TO_DATE function:&lt;/P&gt;
&lt;PRE&gt;TO_DATE('02-OCT-02', 'DD-MON-YY')&lt;/PRE&gt;
&lt;P&gt;or a DATE cast:&lt;/P&gt;
&lt;PRE&gt;DATE '2002-10-03'&lt;/PRE&gt;
&lt;P&gt;See&amp;nbsp;&lt;A href="https://docs.oracle.com/cd/B19306_01/server.102/b14200/sql_elements003.htm" target="_blank" rel="noopener"&gt;https://docs.oracle.com/cd/B19306_01/server.102/b14200/sql_elements003.htm&lt;/A&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please post the complete code of the passthrough&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;execute ( /* explicit pass-through code */ ) by oracle;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If you don't do explicit pass-through (which means that SAS translates values for you), you do not need a formatted date value. See Maxim 28.&lt;/P&gt;</description>
      <pubDate>Wed, 21 Oct 2020 12:46:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/If-Statement-Dates/m-p/693134#M211311</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-10-21T12:46:49Z</dc:date>
    </item>
    <item>
      <title>Re: If Statement - Dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/If-Statement-Dates/m-p/693140#M211314</link>
      <description>It's not a passthrough. I have a library connecting me to an Oracle DB. I set the libname (as below) but I am Unable to query using a Date9 formatted date and the only way I was able to query the date was using SOENTD &amp;gt;= '17Oct2020'd, That's why I needed to set the dates up front using RUN_DATE_SAS = "'" || put(run_date, date9.) || "'d";&lt;BR /&gt;&lt;BR /&gt;libname prd4 oracle path= BI_MTS_PRD4 schema=prdedw user=&amp;amp;useredw password=&amp;amp;passedw dbcommit=1000;</description>
      <pubDate>Wed, 21 Oct 2020 12:51:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/If-Statement-Dates/m-p/693140#M211314</guid>
      <dc:creator>Jyuen204</dc:creator>
      <dc:date>2020-10-21T12:51:46Z</dc:date>
    </item>
    <item>
      <title>Re: If Statement - Dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/If-Statement-Dates/m-p/693148#M211316</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/263957"&gt;@Jyuen204&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;&amp;nbsp;That's why I needed to set the dates up front using RUN_DATE_SAS = "'" || put(run_date, date9.) || "'d";&lt;BR /&gt;&lt;BR /&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;No, you don't. In SAS code, the raw value is sufficient. TRY IT:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let date=%sysfunc(today());

proc sql;
create table test as
  select
    today() as date1,
    '21oct2020'd as date2,
    &amp;amp;date as date3
  from sashelp.class
  where name='Alfred'
;
quit;

proc print data=test;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Result:&lt;/P&gt;
&lt;PRE&gt;Beob.	date1	date2	date3
1	22209	22209	22209
&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 21 Oct 2020 12:59:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/If-Statement-Dates/m-p/693148#M211316</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-10-21T12:59:03Z</dc:date>
    </item>
    <item>
      <title>Re: If Statement - Dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/If-Statement-Dates/m-p/693151#M211318</link>
      <description>&lt;P&gt;And please make up your mind before posting.&lt;/P&gt;
&lt;P&gt;Quote from your earlier post:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;SPAN&gt;I need to format the RUN_DATE to a &lt;STRONG&gt;teradata&lt;/STRONG&gt; format as I am &lt;STRONG&gt;using a passthrough&lt;/STRONG&gt;. &lt;/SPAN&gt;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;And now, we're at no pass-through to Oracle.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 21 Oct 2020 13:01:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/If-Statement-Dates/m-p/693151#M211318</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-10-21T13:01:17Z</dc:date>
    </item>
    <item>
      <title>Re: If Statement - Dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/If-Statement-Dates/m-p/693176#M211327</link>
      <description>And I see that it should be the same. Howe4ver when I run the 2 queries. the query with the '20oct2020'd works and i get results. When I use &amp;amp;run_date_test, i get no results. Stumped&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;data _null_;&lt;BR /&gt;select (weekday(today()));&lt;BR /&gt;  when (3) run_date_test = today() - 3; /* Tuesday */&lt;BR /&gt;  when (4,5,6,7) run_date_test = today() - 1; /* Wednesday to Saturday */&lt;BR /&gt;  otherwise abort abend 5; /* Sunday, Monday */&lt;BR /&gt;end;&lt;BR /&gt;call symputx('run_date_test',run_date_test);&lt;BR /&gt;run;&lt;BR /&gt;&lt;BR /&gt;proc sql;&lt;BR /&gt;  select &amp;amp;run_date_test as date2,&lt;BR /&gt;  		 '20oct2020'd as date3&lt;BR /&gt;  from sashelp.class&lt;BR /&gt;  where name='Alfred';&lt;BR /&gt;quit;&lt;BR /&gt;&lt;BR /&gt;proc sql;&lt;BR /&gt;select * from PRD4.WLNSOTRX_EDWT (obs = 10)&lt;BR /&gt;where SOENTD = &amp;amp;run_date_test;&lt;BR /&gt;run;&lt;BR /&gt;&lt;BR /&gt;proc sql;&lt;BR /&gt;select * from PRD4.WLNSOTRX_EDWT (obs = 10)&lt;BR /&gt;where SOENTD = '20oct2020'd;&lt;BR /&gt;run;</description>
      <pubDate>Wed, 21 Oct 2020 13:38:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/If-Statement-Dates/m-p/693176#M211327</guid>
      <dc:creator>Jyuen204</dc:creator>
      <dc:date>2020-10-21T13:38:33Z</dc:date>
    </item>
  </channel>
</rss>

