<?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: SAS Dates in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/SAS-Dates/m-p/133530#M27123</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The 2012-11 is in a date format that SAS doesn't recognize (or at least an informat that I coudn't find). &lt;/P&gt;&lt;P&gt;If you remove the hyphen, then it is informat, yymmn6. So I compress out the hyphen, convert it to a date. &lt;/P&gt;&lt;P&gt;You were also referencing the incorrect the macro variable in your last macro variable (me), date rather than mydate. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%let date = 2012-11;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%let mydate = %sysfunc(inputn(%sysfunc(compress(&amp;amp;date, "-")), yymmn6.));&lt;/P&gt;&lt;P&gt;%put &amp;amp;mydate;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%let me = %sysfunc(intnx(month,&amp;amp;mydate,-1),yymmd7.);&lt;/P&gt;&lt;P&gt;%put &amp;amp;me;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 14 Mar 2013 15:12:19 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2013-03-14T15:12:19Z</dc:date>
    <item>
      <title>SAS Dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-Dates/m-p/133527#M27120</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Can anyone please provide help me get right answer &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%let date = 2012-11;&lt;/P&gt;&lt;P&gt;%let mydate = %sysfunc(putn(&amp;amp;date, YYMMD7.));&lt;/P&gt;&lt;P&gt;%let me = %sysfunc(intnx(month,&amp;amp;date,-1),yymmd7.);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%put &amp;amp;date;&lt;/P&gt;&lt;P&gt;%put &amp;amp;mydate;&lt;/P&gt;&lt;P&gt;%put &amp;amp;me;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My Answers:&lt;/P&gt;&lt;P&gt;%put &amp;amp;date;&lt;/P&gt;&lt;P&gt;2012-11&lt;/P&gt;&lt;P&gt;%put &amp;amp;mydate;&lt;/P&gt;&lt;P&gt;1965-06&lt;/P&gt;&lt;P&gt;%put &amp;amp;me;&lt;/P&gt;&lt;P&gt;1965-05&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I want Answers:&lt;/P&gt;&lt;P&gt;%put &amp;amp;date;&lt;/P&gt;&lt;P&gt;2012-11&lt;/P&gt;&lt;P&gt;%put &amp;amp;mydate;&lt;/P&gt;&lt;P&gt;2012-11&lt;/P&gt;&lt;P&gt;%put &amp;amp;me;&lt;/P&gt;&lt;P&gt;2012-10&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 13 Mar 2013 20:43:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-Dates/m-p/133527#M27120</guid>
      <dc:creator>helloSAS</dc:creator>
      <dc:date>2013-03-13T20:43:06Z</dc:date>
    </item>
    <item>
      <title>Re: SAS Dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-Dates/m-p/133528#M27121</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;There will be many ways to do this, but here is one suggestion.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue; background: white;"&gt;%let&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt; date = 2012-11;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: green; background: white;"&gt;/* we could use in informat or break out the separate date components, as below */&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue; background: white;"&gt;%let&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt; y=&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue; background: white;"&gt;%substr&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;(%left(&amp;amp;date),1,4);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue; background: white;"&gt;%let&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt; m=&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue; background: white;"&gt;%substr&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;(%left(&amp;amp;date),6,2);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue; background: white;"&gt;%put&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt; y=&amp;amp;y m=&amp;amp;m;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: green; background: white;"&gt;/* create a numerical version of the date */&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue; background: white;"&gt;%let&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt; mydateN = &lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue; background: white;"&gt;%sysfunc&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;(mdy(&amp;amp;m.,1,&amp;amp;y.));&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: green; background: white;"&gt;/* create a Character (formated) version of the date */&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue; background: white;"&gt;%let&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt; mydateF= &lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue; background: white;"&gt;%sysfunc&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;(putn(&amp;amp;mydateN.,yymmd7.));&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: green; background: white;"&gt;/* decrease date and create a new Character (formated) version of the date */&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue; background: white;"&gt;%let&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt; me = &lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue; background: white;"&gt;%sysfunc&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;(intnx(month,&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;&amp;amp;mydateN.&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;,-1),yymmd7.);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue; background: white;"&gt;%put&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;&amp;nbsp; &amp;amp;date;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue; background: white;"&gt;%put&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt; MyDate (Numerical) &amp;amp;mydateN;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue; background: white;"&gt;%put&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt; MyDate (Formated) &amp;amp;mydateF;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue; background: white;"&gt;%put&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt; &amp;amp;me;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 14 Mar 2013 14:12:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-Dates/m-p/133528#M27121</guid>
      <dc:creator>ChrisWard</dc:creator>
      <dc:date>2013-03-14T14:12:37Z</dc:date>
    </item>
    <item>
      <title>Re: SAS Dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-Dates/m-p/133529#M27122</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi.&lt;/P&gt;&lt;P&gt;I think&amp;nbsp; the main problem is in the first assignment of date:&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;%let date = 2012-11;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;While the assumption is that SAS will know what you mean, it is hard without telling SAS that '2012-11' is actually a date, it will not just guess that.&lt;/P&gt;&lt;P&gt;OK, the more straightforward explanation is that SAS will not just assume that the list of characters: &lt;STRONG&gt;2012-11&lt;/STRONG&gt; means a date. Unless YOU tell it so.&lt;/P&gt;&lt;P&gt;In a %let statement you can have anything: %let date = this is a date, so that means you cannot simply apply a specific date format to a string and expect SAS to know what you mean.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So, again, &lt;STRONG&gt;%let date = 2012-11; translates to a string that does not have the meaning you intended (date). It is just a string of numbers.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;BR /&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;So,&lt;STRONG&gt; &lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;%let date = 2012-11; needs to become something like&lt;BR /&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;%let date = '01Nov2012'd;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;%put &amp;amp;date;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%let mydate = %sysfunc(putn(&amp;amp;date, yymmd7.));&lt;/P&gt;&lt;P&gt;%put &amp;amp;mydate.;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%let me = %sysfunc(intnx(Month,&amp;amp;date., -1),yymmd7.); &lt;/P&gt;&lt;P&gt;%put &amp;amp;me.;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I hope this clarifies a bit why you are not getting the expected answers.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Good luck,&lt;/P&gt;&lt;P&gt;Anca&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 14 Mar 2013 14:25:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-Dates/m-p/133529#M27122</guid>
      <dc:creator>AncaTilea</dc:creator>
      <dc:date>2013-03-14T14:25:04Z</dc:date>
    </item>
    <item>
      <title>Re: SAS Dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-Dates/m-p/133530#M27123</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The 2012-11 is in a date format that SAS doesn't recognize (or at least an informat that I coudn't find). &lt;/P&gt;&lt;P&gt;If you remove the hyphen, then it is informat, yymmn6. So I compress out the hyphen, convert it to a date. &lt;/P&gt;&lt;P&gt;You were also referencing the incorrect the macro variable in your last macro variable (me), date rather than mydate. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%let date = 2012-11;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%let mydate = %sysfunc(inputn(%sysfunc(compress(&amp;amp;date, "-")), yymmn6.));&lt;/P&gt;&lt;P&gt;%put &amp;amp;mydate;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%let me = %sysfunc(intnx(month,&amp;amp;mydate,-1),yymmd7.);&lt;/P&gt;&lt;P&gt;%put &amp;amp;me;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 14 Mar 2013 15:12:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-Dates/m-p/133530#M27123</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2013-03-14T15:12:19Z</dc:date>
    </item>
    <item>
      <title>Re: SAS Dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-Dates/m-p/133531#M27124</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you all for your feedback. I've a working code now. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 14 Mar 2013 18:23:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-Dates/m-p/133531#M27124</guid>
      <dc:creator>helloSAS</dc:creator>
      <dc:date>2013-03-14T18:23:50Z</dc:date>
    </item>
  </channel>
</rss>

