<?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: getting last month from year month date in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/getting-last-month-from-year-month-date/m-p/816300#M322180</link>
    <description>&lt;PRE&gt;%let yearmonth = 202210;

%let last_month=%sysfunc(intnx(month, %sysfunc(inputn(&amp;amp;yearmonth.,yymmn6.)) ,-1),yymmn6.) ;

%put &amp;amp;=last_month. ;&lt;/PRE&gt;</description>
    <pubDate>Fri, 03 Jun 2022 08:13:56 GMT</pubDate>
    <dc:creator>Ksharp</dc:creator>
    <dc:date>2022-06-03T08:13:56Z</dc:date>
    <item>
      <title>getting last month from year month date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/getting-last-month-from-year-month-date/m-p/816291#M322176</link>
      <description>&lt;P&gt;Hi All,&lt;/P&gt;&lt;P&gt;I have&amp;nbsp; a date in the form of year month and I want the last month date from the code . for eg I have 202210 and I want the code to provide me 202209.&lt;/P&gt;&lt;P&gt;tried code below but didn't work.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;%let yearmonth = 202210;

data one;
	call symputx('P_Month', month(intnx('month',&amp;amp;yearmonth,-1)));
run;

%put &amp;amp;P_Month;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 03 Jun 2022 03:54:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/getting-last-month-from-year-month-date/m-p/816291#M322176</guid>
      <dc:creator>kajal_30</dc:creator>
      <dc:date>2022-06-03T03:54:48Z</dc:date>
    </item>
    <item>
      <title>Re: getting last month from year month date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/getting-last-month-from-year-month-date/m-p/816292#M322177</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let yearmonth = 202210;

data _null_;
   dt = input(put(&amp;amp;yearmonth., 6.), yymmn6.);
   call symputx('P_Month', put(intnx('month', dt, -1, 'b'), yymmn6.));
run;

%put &amp;amp;P_Month.;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 03 Jun 2022 04:10:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/getting-last-month-from-year-month-date/m-p/816292#M322177</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2022-06-03T04:10:36Z</dc:date>
    </item>
    <item>
      <title>Re: getting last month from year month date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/getting-last-month-from-year-month-date/m-p/816293#M322178</link>
      <description>&lt;P&gt;SAS dates are counts of days, with 1960-01-01 being day zero.&lt;/P&gt;
&lt;P&gt;So your INTNX function starts with a date that is 202,210 days after 1960-01-01, so quite far in the future.&lt;/P&gt;
&lt;P&gt;As already indicated, you must convert your year/month string to a SAS date first by using the INPUT function with a proper informat.&lt;/P&gt;</description>
      <pubDate>Fri, 03 Jun 2022 04:21:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/getting-last-month-from-year-month-date/m-p/816293#M322178</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2022-06-03T04:21:11Z</dc:date>
    </item>
    <item>
      <title>Re: getting last month from year month date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/getting-last-month-from-year-month-date/m-p/816300#M322180</link>
      <description>&lt;PRE&gt;%let yearmonth = 202210;

%let last_month=%sysfunc(intnx(month, %sysfunc(inputn(&amp;amp;yearmonth.,yymmn6.)) ,-1),yymmn6.) ;

%put &amp;amp;=last_month. ;&lt;/PRE&gt;</description>
      <pubDate>Fri, 03 Jun 2022 08:13:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/getting-last-month-from-year-month-date/m-p/816300#M322180</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2022-06-03T08:13:56Z</dc:date>
    </item>
    <item>
      <title>Re: getting last month from year month date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/getting-last-month-from-year-month-date/m-p/816332#M322191</link>
      <description>&lt;P&gt;Thank you so much team.&lt;/P&gt;</description>
      <pubDate>Fri, 03 Jun 2022 14:34:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/getting-last-month-from-year-month-date/m-p/816332#M322191</guid>
      <dc:creator>kajal_30</dc:creator>
      <dc:date>2022-06-03T14:34:45Z</dc:date>
    </item>
  </channel>
</rss>

