<?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: want to convert date in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/want-to-convert-date/m-p/731117#M227743</link>
    <description>&lt;P&gt;First of all, you need to know the notation of a date literal for the DBMS you send the code to. Then you can build the cast directive with the proper format.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But with such a simple WHERE, I would forego the explicit pass-through and let SAS handle the conversion in an implicit one (define a ODBC LIBNAME and pull the data from that).&lt;/P&gt;</description>
    <pubDate>Sat, 03 Apr 2021 09:17:47 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2021-04-03T09:17:47Z</dc:date>
    <item>
      <title>want to convert date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/want-to-convert-date/m-p/731115#M227742</link>
      <description>&lt;P&gt;Hi need help in converting the date :&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;today() =20210403 or today()=202104i.e(yyyymm)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;as in some database the data is in 20210403 and variable type as numeric.&lt;/P&gt;
&lt;P&gt;so for fetching date using a passthrough we have to pass manually done in below code&lt;/P&gt;
&lt;P&gt;how can i automate the passing of load_date variable.&lt;/P&gt;
&lt;P&gt;options compress=yes;&lt;BR /&gt;proc sql ;&lt;BR /&gt;connect to odbc(&lt;BR /&gt;datasrc='asdf'&lt;BR /&gt;user='sdfgth' &lt;BR /&gt;password='ddddxxxxxxxx' &lt;BR /&gt;);&lt;BR /&gt;create table ADVICE_raw as&lt;BR /&gt;select * from connection to odbc&lt;BR /&gt;(&lt;BR /&gt;Select * from wdf.advice_vw&lt;BR /&gt;where load_date &amp;gt;=20210301;&lt;BR /&gt;);&lt;/P&gt;
&lt;P&gt;disconnect from odbc;&lt;BR /&gt;quit;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;so in the above code load_date&amp;gt;=20210301&lt;/P&gt;</description>
      <pubDate>Sat, 03 Apr 2021 08:19:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/want-to-convert-date/m-p/731115#M227742</guid>
      <dc:creator>anirudhs</dc:creator>
      <dc:date>2021-04-03T08:19:17Z</dc:date>
    </item>
    <item>
      <title>Re: want to convert date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/want-to-convert-date/m-p/731117#M227743</link>
      <description>&lt;P&gt;First of all, you need to know the notation of a date literal for the DBMS you send the code to. Then you can build the cast directive with the proper format.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But with such a simple WHERE, I would forego the explicit pass-through and let SAS handle the conversion in an implicit one (define a ODBC LIBNAME and pull the data from that).&lt;/P&gt;</description>
      <pubDate>Sat, 03 Apr 2021 09:17:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/want-to-convert-date/m-p/731117#M227743</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2021-04-03T09:17:47Z</dc:date>
    </item>
    <item>
      <title>Re: want to convert date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/want-to-convert-date/m-p/731138#M227749</link>
      <description>&lt;P&gt;Below should work.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;options compress=yes;
proc sql;
  connect to odbc(
    datasrc='asdf'
    user='sdfgth'
    password='ddddxxxxxxxx'
    );
  create table ADVICE_raw as
    select * from connection to odbc
      (
    Select * from wdf.advice_vw
      where load_date &amp;gt;=%sysfunc(today(),yymmddn8.);
      );
  disconnect from odbc;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 03 Apr 2021 14:16:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/want-to-convert-date/m-p/731138#M227749</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2021-04-03T14:16:15Z</dc:date>
    </item>
    <item>
      <title>Re: want to convert date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/want-to-convert-date/m-p/731142#M227752</link>
      <description>&lt;P&gt;So you are saying that in the remote database they are literally storing 03APR2021 as the number 20,210,403 ?&lt;/P&gt;
&lt;P&gt;Or does the database have an actual concept of storing date but allows code to reference them with a string that looks like any integer instead?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you just want to generate a string in YYYYMMDD style then you can use the YYMMDDN8. format.&lt;/P&gt;
&lt;P&gt;For example you could build a macro variable named TODAY with the string for today's date by using %SYSFUNC() to call the TODAY() function and format the result with the YYMMDDN8. format.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%put today=%sysfunc(today(),yymmddn8.);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;You could then reference that macro variable in place where you want that string of digits to appear in the code.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;where load_date &amp;gt;= &amp;amp;today.&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 03 Apr 2021 14:50:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/want-to-convert-date/m-p/731142#M227752</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-04-03T14:50:03Z</dc:date>
    </item>
    <item>
      <title>Re: want to convert date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/want-to-convert-date/m-p/731150#M227757</link>
      <description>and how can i pass the yyyymm (202104) instead of the full date ??</description>
      <pubDate>Sat, 03 Apr 2021 15:44:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/want-to-convert-date/m-p/731150#M227757</guid>
      <dc:creator>anirudhs</dc:creator>
      <dc:date>2021-04-03T15:44:53Z</dc:date>
    </item>
    <item>
      <title>Re: want to convert date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/want-to-convert-date/m-p/731152#M227759</link>
      <description>Hi Kurt,&lt;BR /&gt;&lt;BR /&gt;Actually i tried that but we are fetching this data from the hadoop DB and there is some issue with the driver so , it was suggested to use the pass-through. &lt;BR /&gt;As i find datastep more easy.</description>
      <pubDate>Sat, 03 Apr 2021 15:46:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/want-to-convert-date/m-p/731152#M227759</guid>
      <dc:creator>anirudhs</dc:creator>
      <dc:date>2021-04-03T15:46:42Z</dc:date>
    </item>
    <item>
      <title>Re: want to convert date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/want-to-convert-date/m-p/731156#M227761</link>
      <description>&lt;P&gt;The YYMMN6. format will produce strings in YYYYMM style.&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let thismonth=%sysfunc(today(),yymmn6.);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Or just use %SUBSTR() to take the first 6 characters from the 8 character string you generated with the full date.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let thismonth=%substr(&amp;amp;today,1,6);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 03 Apr 2021 16:29:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/want-to-convert-date/m-p/731156#M227761</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-04-03T16:29:34Z</dc:date>
    </item>
  </channel>
</rss>

