<?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: First and Last day using proc - date is character in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/First-and-Last-day-using-proc-date-is-character/m-p/729612#M227088</link>
    <description>&lt;P&gt;This needs to be fixed at the point where the data enters your SAS environment.&lt;/P&gt;
&lt;P&gt;Date values must (I use that word intentionally here) always be stored as SAS dates.&lt;/P&gt;
&lt;P&gt;From where does the data originate (database, text file, Excel spreadsheet, ...)?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Next, you need to use ANSI SQL and SAS syntax, the available columns, and the functions available in SAS. I&amp;nbsp;&lt;EM&gt;guess&lt;/EM&gt; you want this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;where intnx('month',today(),0,'b') le my_date le intnx('month',today(),0,'e')&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;or&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;where month(my_date) = month(today()) and year(my_date) = year(today())&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;or&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;where put(my_date,yymmn6.) = put(today(),yymmn6.)&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Sun, 28 Mar 2021 07:06:28 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2021-03-28T07:06:28Z</dc:date>
    <item>
      <title>First and Last day using proc - date is character</title>
      <link>https://communities.sas.com/t5/SAS-Programming/First-and-Last-day-using-proc-date-is-character/m-p/729601#M227082</link>
      <description>&lt;P&gt;data have;&lt;BR /&gt;infile datalines;&lt;BR /&gt;input my_date $20.;&lt;BR /&gt;return;&lt;BR /&gt;datalines;&lt;BR /&gt;02/01/2021&lt;BR /&gt;02/28/2021&lt;BR /&gt;01/21/2021&lt;BR /&gt;;run;&lt;/P&gt;
&lt;P&gt;proc sql;&lt;BR /&gt;create table want as&lt;BR /&gt;select input(my_date,mmddyy10.) as new_date format=mmddyy10.&lt;BR /&gt;from have&lt;BR /&gt;where input(my_date,mmddyy10.) between first_day(add_months(current_date, -1))&lt;BR /&gt;and last_day(add_months(current_date, -1))&lt;BR /&gt;;quit;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The initial data shows the date as a character.&amp;nbsp; I attempted to convert it to a date.&amp;nbsp; I then want to select a date range however since the date initially is a character, how would I convert it so I can eliminate the data match errors&lt;/P&gt;</description>
      <pubDate>Sun, 28 Mar 2021 03:12:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/First-and-Last-day-using-proc-date-is-character/m-p/729601#M227082</guid>
      <dc:creator>Q1983</dc:creator>
      <dc:date>2021-03-28T03:12:12Z</dc:date>
    </item>
    <item>
      <title>Re: First and Last day using proc - date is character</title>
      <link>https://communities.sas.com/t5/SAS-Programming/First-and-Last-day-using-proc-date-is-character/m-p/729608#M227086</link>
      <description>&lt;P&gt;Just replace the functions that cannot be used in proc sql with SAS functions.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
  create table want as
    select input(my_date,mmddyy10.) as new_date format=mmddyy10.
    from have
    where input(my_date,mmddyy10.) between INTNX('MONTH', today(), -1,'BEGINNING')
      and INTNX('MONTH', today(), -1,'END')
;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 28 Mar 2021 06:13:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/First-and-Last-day-using-proc-date-is-character/m-p/729608#M227086</guid>
      <dc:creator>japelin</dc:creator>
      <dc:date>2021-03-28T06:13:54Z</dc:date>
    </item>
    <item>
      <title>Re: First and Last day using proc - date is character</title>
      <link>https://communities.sas.com/t5/SAS-Programming/First-and-Last-day-using-proc-date-is-character/m-p/729612#M227088</link>
      <description>&lt;P&gt;This needs to be fixed at the point where the data enters your SAS environment.&lt;/P&gt;
&lt;P&gt;Date values must (I use that word intentionally here) always be stored as SAS dates.&lt;/P&gt;
&lt;P&gt;From where does the data originate (database, text file, Excel spreadsheet, ...)?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Next, you need to use ANSI SQL and SAS syntax, the available columns, and the functions available in SAS. I&amp;nbsp;&lt;EM&gt;guess&lt;/EM&gt; you want this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;where intnx('month',today(),0,'b') le my_date le intnx('month',today(),0,'e')&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;or&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;where month(my_date) = month(today()) and year(my_date) = year(today())&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;or&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;where put(my_date,yymmn6.) = put(today(),yymmn6.)&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 28 Mar 2021 07:06:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/First-and-Last-day-using-proc-date-is-character/m-p/729612#M227088</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2021-03-28T07:06:28Z</dc:date>
    </item>
  </channel>
</rss>

