<?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: i am trying to add '-'between date9. in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/i-am-trying-to-add-between-date9/m-p/940958#M369285</link>
    <description>&lt;P&gt;Hi Chris!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank&amp;nbsp; you for you reply!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am trying to do a lookup from oracle table and SAS Dataset to check the sales and area, to create a report of sales and salesperson for dates and on oracle tables the dates are -'01-JAN-00' . please suggest if i can use cast to convert the date only for comparison.&lt;/P&gt;</description>
    <pubDate>Tue, 27 Aug 2024 05:23:46 GMT</pubDate>
    <dc:creator>Santt0sh</dc:creator>
    <dc:date>2024-08-27T05:23:46Z</dc:date>
    <item>
      <title>i am trying to add '-'between date9.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/i-am-trying-to-add-between-date9/m-p/940951#M369282</link>
      <description>&lt;P&gt;Hi Experts,&lt;/P&gt;
&lt;P&gt;Iam trying to add '-'hypen between date.&lt;/P&gt;
&lt;P&gt;01JAN2000&lt;/P&gt;
&lt;P&gt;to&lt;/P&gt;
&lt;P&gt;01-JAN-00&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please find the Code&amp;nbsp; and logs.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Kindly suggest.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let dsn = sales_region_200003;
%let ndte = %sysfunc(TRANWRD(%sysfunc(putn(%sysfunc(inputn(%scan(&amp;amp;dsn,-1,'_'),yymmn6.)),date9.)),' ','-'));

%put &amp;amp;ndte;



LOG:

 
 1          OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
 68         
 69         %let dsn = sales_region_200003;
 70         %let ndte = %sysfunc(TRANWRD(%sysfunc(putn(%sysfunc(inputn(%scan(&amp;amp;dsn,-1,'_'),yymmn6.)),date9.)),' ','-'));
 71         
 72         %put &amp;amp;ndte;
 01MAR2000
 73         
 74         OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
 84         &lt;/CODE&gt;&lt;/PRE&gt;
&lt;PRE&gt; 
 1          OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
 68         
 69         %let dsn = sales_region_200003;
 70         %let ndte = %sysfunc(TRANWRD(%sysfunc(putn(%sysfunc(inputn(%scan(&amp;amp;dsn,-1,'_'),yymmn6.)),date9.)),' ','-'));
 71         
 72         %put &amp;amp;ndte;
 01MAR2000
 73         
 74         OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
 84         &lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 27 Aug 2024 03:24:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/i-am-trying-to-add-between-date9/m-p/940951#M369282</guid>
      <dc:creator>Santt0sh</dc:creator>
      <dc:date>2024-08-27T03:24:36Z</dc:date>
    </item>
    <item>
      <title>Re: i am trying to add '-'between date9.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/i-am-trying-to-add-between-date9/m-p/940953#M369284</link>
      <description>&lt;P&gt;You really should keep the year whole.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%put ndte = %sysfunc(inputn(%scan(&amp;amp;dsn, -1, _), yymmn6.), date11.);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;CODE class=" language-sas"&gt;ndte = 01-MAR-2000&lt;/CODE&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also this question has been asked before.&lt;/P&gt;
&lt;P&gt;&lt;A href="https://communities.sas.com/t5/SAS-Procedures/Reg-Date-in-DD-MMM-YY/td-p/55232" target="_blank" rel="noopener"&gt;https://communities.sas.com/t5/SAS-Procedures/Reg-Date-in-DD-MMM-YY/td-p/55232&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 27 Aug 2024 04:08:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/i-am-trying-to-add-between-date9/m-p/940953#M369284</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2024-08-27T04:08:18Z</dc:date>
    </item>
    <item>
      <title>Re: i am trying to add '-'between date9.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/i-am-trying-to-add-between-date9/m-p/940958#M369285</link>
      <description>&lt;P&gt;Hi Chris!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank&amp;nbsp; you for you reply!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am trying to do a lookup from oracle table and SAS Dataset to check the sales and area, to create a report of sales and salesperson for dates and on oracle tables the dates are -'01-JAN-00' . please suggest if i can use cast to convert the date only for comparison.&lt;/P&gt;</description>
      <pubDate>Tue, 27 Aug 2024 05:23:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/i-am-trying-to-add-between-date9/m-p/940958#M369285</guid>
      <dc:creator>Santt0sh</dc:creator>
      <dc:date>2024-08-27T05:23:46Z</dc:date>
    </item>
    <item>
      <title>Re: i am trying to add '-'between date9.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/i-am-trying-to-add-between-date9/m-p/940959#M369286</link>
      <description>&lt;P&gt;I'm pretty sure Oracle understands 4-digit years '01-JAN-2000' .&lt;/P&gt;</description>
      <pubDate>Tue, 27 Aug 2024 05:26:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/i-am-trying-to-add-between-date9/m-p/940959#M369286</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2024-08-27T05:26:01Z</dc:date>
    </item>
    <item>
      <title>Re: i am trying to add '-'between date9.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/i-am-trying-to-add-between-date9/m-p/940962#M369287</link>
      <description>&lt;P&gt;My preference is to code&lt;/P&gt;
&lt;P&gt;&lt;CODE class=" language-sas"&gt;date '2017-01-21'&lt;/CODE&gt;&lt;/P&gt;
&lt;P&gt;to avoid any confusion.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 27 Aug 2024 05:41:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/i-am-trying-to-add-between-date9/m-p/940962#M369287</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2024-08-27T05:41:39Z</dc:date>
    </item>
    <item>
      <title>Re: i am trying to add '-'between date9.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/i-am-trying-to-add-between-date9/m-p/941056#M369302</link>
      <description>&lt;P&gt;Hi Chris!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I will make a note of this!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you for your help!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 27 Aug 2024 13:40:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/i-am-trying-to-add-between-date9/m-p/941056#M369302</guid>
      <dc:creator>Santt0sh</dc:creator>
      <dc:date>2024-08-27T13:40:35Z</dc:date>
    </item>
    <item>
      <title>Re: i am trying to add '-'between date9.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/i-am-trying-to-add-between-date9/m-p/941120#M369316</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/183704"&gt;@Santt0sh&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;My general rule here is that life is always more difficult when you try to handle dates as characters strings, that must be pulled apart somehow, modified, and then re-assembled. Just be cause you can do it this way does not mean you should do it this way.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Dates are much easier to handle as numeric variables. Not only can you use built in formats such as DATE9. or DATE11. (and many others), but you can create your own if the built in formats don't get the job done. So, look how easy this is using the PROC FORMAT PICTURE statement:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc format;
    picture datedash low-high ='%0d-%b-%y'(datatype=date);
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Now you have a format that has dashes in it and two-digit year that you can apply to any valid numeric SAS date value.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
    date='01JAN2024'd;
    output;
    date='22FEB2024'd;
    output;
    format date datedash.;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Even though you marked an answer as correct above, I hope you and everyone else reading this far will consider this approach, I consider it superior to the method that pulls strings apart, makes changes, and then reassembles the string. Plus, since the variable is numeric, it will sort properly, and you can perform arithmetic or boolean logic on them, which you cannot do with strings representing dates.&lt;/P&gt;</description>
      <pubDate>Tue, 27 Aug 2024 17:53:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/i-am-trying-to-add-between-date9/m-p/941120#M369316</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2024-08-27T17:53:25Z</dc:date>
    </item>
    <item>
      <title>Re: i am trying to add '-'between date9.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/i-am-trying-to-add-between-date9/m-p/941129#M369318</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/183704"&gt;@Santt0sh&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hi Chris!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank&amp;nbsp; you for you reply!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am trying to do a lookup from oracle table and SAS Dataset to check the sales and area, to create a report of sales and salesperson for dates and on oracle tables the dates are -'01-JAN-00' . please suggest if i can use cast to convert the date only for comparison.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;How do you connect to Oracle?&lt;/P&gt;
&lt;P&gt;I would think that the SAS Access for Oracle would handle the date conversions for you.&lt;/P&gt;</description>
      <pubDate>Tue, 27 Aug 2024 17:45:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/i-am-trying-to-add-between-date9/m-p/941129#M369318</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2024-08-27T17:45:16Z</dc:date>
    </item>
    <item>
      <title>Re: i am trying to add '-'between date9.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/i-am-trying-to-add-between-date9/m-p/941202#M369319</link>
      <description>&lt;P&gt;Hi Supre_User,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Use Libname or Pass thru to connect, and it did work.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you for you help.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 27 Aug 2024 21:09:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/i-am-trying-to-add-between-date9/m-p/941202#M369319</guid>
      <dc:creator>Santt0sh</dc:creator>
      <dc:date>2024-08-27T21:09:43Z</dc:date>
    </item>
    <item>
      <title>Re: i am trying to add '-'between date9.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/i-am-trying-to-add-between-date9/m-p/941206#M369321</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/10892"&gt;@PaigeMiller&lt;/a&gt; You can also build in the single quotes that Oracle requires.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc format;
  picture dateora low-high ='''%0d-%b-%y''' (datatype=date);
run;

data TEST;
  DATE='01JAN2024'd; 
  putlog DATE= dateora. ;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;PRE id="pre_sasLog_105162" class="sasLog" style="background-color: transparent; -webkit-user-select: text; -webkit-user-modify: read-only; -webkit-touch-callout: default; border-top-width: 0px; border-bottom-width: 0px;"&gt;&lt;FONT face="courier new,courier"&gt;DATE='01-Jan-24'&lt;/FONT&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 27 Aug 2024 22:32:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/i-am-trying-to-add-between-date9/m-p/941206#M369321</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2024-08-27T22:32:56Z</dc:date>
    </item>
  </channel>
</rss>

