<?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: How to provide the year based on month in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-provide-the-year-based-on-month/m-p/794219#M254652</link>
    <description>&lt;P&gt;Using first/last, lag-function and assuming that the data is sorted by "Group":&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
   set have;
   by Group;
   
   retain Year;
   
   LastMonth = lag(Month);
   
   if first.Group then do;
      Year = 2021;
      LastMonth = Month - 1;
   end;
   
   if Month ^= LastMonth + 1 then do;
      Year = Year + 1;
   end;
   
   drop LastMonth;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Thu, 03 Feb 2022 14:18:36 GMT</pubDate>
    <dc:creator>andreas_lds</dc:creator>
    <dc:date>2022-02-03T14:18:36Z</dc:date>
    <item>
      <title>How to provide the year based on month</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-provide-the-year-based-on-month/m-p/794217#M254650</link>
      <description>&lt;P&gt;Hi Team,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please help me to get year based on month ......&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In Below example ...... How to get Excepting output Column&lt;/P&gt;&lt;P&gt;Group Month Expecting output&lt;BR /&gt;Abc&amp;nbsp; &amp;nbsp; &amp;nbsp;11&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 2021&lt;BR /&gt;Abc&amp;nbsp; &amp;nbsp; &amp;nbsp;12&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 2021&lt;BR /&gt;Abc&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 2022&lt;BR /&gt;Abc&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;2&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 2022&lt;BR /&gt;Abc&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;3&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 2022&lt;BR /&gt;Abc&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;4&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 2022&lt;BR /&gt;Abc&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;5&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;2022&lt;BR /&gt;Abc&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;6&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;2022&lt;BR /&gt;Abc&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;7&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;2022&lt;BR /&gt;Abc&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;8&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;2022&lt;BR /&gt;Abc&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;9&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;2022&lt;BR /&gt;Abc&amp;nbsp; &amp;nbsp; &amp;nbsp;10&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;2022&lt;BR /&gt;Abc&amp;nbsp; &amp;nbsp; &amp;nbsp;11&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;2022&lt;BR /&gt;Abc&amp;nbsp; &amp;nbsp; &amp;nbsp;12&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 2022&lt;BR /&gt;Abc&amp;nbsp; &amp;nbsp; &amp;nbsp;1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 2023&lt;BR /&gt;Abc&amp;nbsp; &amp;nbsp; &amp;nbsp;2&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 2023&lt;BR /&gt;BVC&amp;nbsp; &amp;nbsp;12&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 2021&lt;BR /&gt;BVC&amp;nbsp; &amp;nbsp; 1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;2022&lt;BR /&gt;BVC&amp;nbsp; &amp;nbsp; 2&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;2022&lt;BR /&gt;BVC&amp;nbsp; &amp;nbsp; 3&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;2022&lt;BR /&gt;BVC&amp;nbsp; &amp;nbsp; 4&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 2022&lt;BR /&gt;BVC&amp;nbsp; &amp;nbsp; 5&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;2022&lt;BR /&gt;BVC&amp;nbsp; &amp;nbsp; 6&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 2022&lt;BR /&gt;BVC&amp;nbsp; &amp;nbsp; 7&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 2022&lt;BR /&gt;BVC&amp;nbsp; &amp;nbsp; 8&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 2022&lt;BR /&gt;BVC&amp;nbsp; &amp;nbsp; 9&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 2022&lt;BR /&gt;BVC&amp;nbsp; &amp;nbsp;10&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;2022&lt;BR /&gt;BVC&amp;nbsp; &amp;nbsp; 11&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 2022&lt;BR /&gt;BVC&amp;nbsp; &amp;nbsp; 12&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 2022&lt;BR /&gt;BVC&amp;nbsp; &amp;nbsp; &amp;nbsp;1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 2023&lt;BR /&gt;BVC&amp;nbsp; &amp;nbsp; &amp;nbsp;2&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 2023&lt;/P&gt;</description>
      <pubDate>Thu, 03 Feb 2022 13:32:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-provide-the-year-based-on-month/m-p/794217#M254650</guid>
      <dc:creator>Sharath_naik</dc:creator>
      <dc:date>2022-02-03T13:32:05Z</dc:date>
    </item>
    <item>
      <title>Re: How to provide the year based on month</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-provide-the-year-based-on-month/m-p/794218#M254651</link>
      <description>&lt;P&gt;You can't derive a year from a month without strict rules about how to do this, which you don't explain. Rather than me guess and potentially get it wrong, please explain the logic that creates the expected column.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 03 Feb 2022 13:48:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-provide-the-year-based-on-month/m-p/794218#M254651</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2022-02-03T13:48:23Z</dc:date>
    </item>
    <item>
      <title>Re: How to provide the year based on month</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-provide-the-year-based-on-month/m-p/794219#M254652</link>
      <description>&lt;P&gt;Using first/last, lag-function and assuming that the data is sorted by "Group":&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
   set have;
   by Group;
   
   retain Year;
   
   LastMonth = lag(Month);
   
   if first.Group then do;
      Year = 2021;
      LastMonth = Month - 1;
   end;
   
   if Month ^= LastMonth + 1 then do;
      Year = Year + 1;
   end;
   
   drop LastMonth;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 03 Feb 2022 14:18:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-provide-the-year-based-on-month/m-p/794219#M254652</guid>
      <dc:creator>andreas_lds</dc:creator>
      <dc:date>2022-02-03T14:18:36Z</dc:date>
    </item>
    <item>
      <title>Re: How to provide the year based on month</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-provide-the-year-based-on-month/m-p/794245#M254667</link>
      <description>&lt;P&gt;From your data, this should do it:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
set have;
by group;
if first.group then year = 2021;
if month = 1 then year + 1;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 03 Feb 2022 15:42:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-provide-the-year-based-on-month/m-p/794245#M254667</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2022-02-03T15:42:20Z</dc:date>
    </item>
  </channel>
</rss>

