<?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 How to provide a same value for consecutive years, and so on? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-provide-a-same-value-for-consecutive-years-and-so-on/m-p/798731#M313998</link>
    <description>&lt;P&gt;Hi all,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you in advance,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a panel data like the following:&amp;nbsp;&lt;/P&gt;&lt;P&gt;ID CUSIP YEAR&lt;BR /&gt;2 201647 1994&lt;BR /&gt;3 20030N 1987&lt;BR /&gt;3 20030N 1988&lt;BR /&gt;3 20030N 1989&lt;BR /&gt;3 20030N 1991&lt;BR /&gt;3 20030N 1996&lt;BR /&gt;3 20030N 1997&lt;BR /&gt;3 20030N 1998&lt;BR /&gt;4 073902 1992&lt;BR /&gt;4 073902 1993&lt;BR /&gt;6 561232 1995&lt;BR /&gt;8 552848 2002&lt;BR /&gt;8 552848 2004&lt;BR /&gt;8 552848 2007&lt;BR /&gt;8 62945J 1987&lt;BR /&gt;8 62945J 1988&lt;BR /&gt;8 929903 1991&lt;BR /&gt;8 929903 1992&lt;BR /&gt;8 929903 1994&lt;BR /&gt;12 08658U 1995&lt;BR /&gt;12 08658U 1996&lt;BR /&gt;12 08658U 1997&lt;BR /&gt;13 001547 2007&lt;BR /&gt;13 001547 2008&lt;BR /&gt;13 001547 2011&lt;BR /&gt;13 001547 2012&lt;BR /&gt;13 001547 2014&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;By group ID-CUSIP, I want to endow a same value for consecutive years. And, if there is a jump in year, consecutive years from that year on will be endowed another yet same value.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The results I want to obtain are:&amp;nbsp;&lt;/P&gt;&lt;P&gt;ID CUSIP YEAR Newvar&lt;BR /&gt;2 201647 1994&amp;nbsp; &amp;nbsp; &amp;nbsp; 1&lt;BR /&gt;3 20030N 1987&amp;nbsp; &amp;nbsp; &amp;nbsp;1&lt;BR /&gt;3 20030N 1988&amp;nbsp; &amp;nbsp; &amp;nbsp;1&lt;BR /&gt;3 20030N 1989&amp;nbsp; &amp;nbsp; &amp;nbsp;1&lt;BR /&gt;3 20030N 1991&amp;nbsp; &amp;nbsp; &amp;nbsp;2&lt;BR /&gt;3 20030N 1996&amp;nbsp; &amp;nbsp; &amp;nbsp;3&lt;BR /&gt;3 20030N 1997&amp;nbsp; &amp;nbsp; &amp;nbsp;3&lt;BR /&gt;3 20030N 1998&amp;nbsp; &amp;nbsp; &amp;nbsp;3&lt;BR /&gt;4 073902 1992&amp;nbsp; &amp;nbsp; &amp;nbsp;1&lt;BR /&gt;4 073902 1993&amp;nbsp; &amp;nbsp; &amp;nbsp;1&lt;BR /&gt;6 561232 1995&amp;nbsp; &amp;nbsp; &amp;nbsp;1&lt;BR /&gt;8 552848 2002&amp;nbsp; &amp;nbsp; 1&lt;BR /&gt;8 552848 2004&amp;nbsp; &amp;nbsp; 2&lt;BR /&gt;8 552848 2007&amp;nbsp; &amp;nbsp; 3&lt;BR /&gt;8 62945J 1987&amp;nbsp; &amp;nbsp; 1&lt;BR /&gt;8 62945J 1988&amp;nbsp; &amp;nbsp; 1&lt;BR /&gt;8 929903 1991&amp;nbsp; &amp;nbsp; 1&lt;BR /&gt;8 929903 1992&amp;nbsp; &amp;nbsp; 1&lt;BR /&gt;8 929903 1994&amp;nbsp; &amp;nbsp; 2&lt;BR /&gt;12 08658U 1995&amp;nbsp; 1&lt;BR /&gt;12 08658U 1996&amp;nbsp; 1&lt;BR /&gt;12 08658U 1997&amp;nbsp; 1&lt;BR /&gt;13 001547 2007&amp;nbsp; 1&lt;BR /&gt;13 001547 2008&amp;nbsp; 1&lt;BR /&gt;13 001547 2011&amp;nbsp; 2&lt;BR /&gt;13 001547 2012&amp;nbsp; 2&lt;BR /&gt;13 001547 2014&amp;nbsp; 3&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I sincerely thank you all for your wonderful help!&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;KS -,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 25 Feb 2022 19:45:17 GMT</pubDate>
    <dc:creator>KS99</dc:creator>
    <dc:date>2022-02-25T19:45:17Z</dc:date>
    <item>
      <title>How to provide a same value for consecutive years, and so on?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-provide-a-same-value-for-consecutive-years-and-so-on/m-p/798731#M313998</link>
      <description>&lt;P&gt;Hi all,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you in advance,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a panel data like the following:&amp;nbsp;&lt;/P&gt;&lt;P&gt;ID CUSIP YEAR&lt;BR /&gt;2 201647 1994&lt;BR /&gt;3 20030N 1987&lt;BR /&gt;3 20030N 1988&lt;BR /&gt;3 20030N 1989&lt;BR /&gt;3 20030N 1991&lt;BR /&gt;3 20030N 1996&lt;BR /&gt;3 20030N 1997&lt;BR /&gt;3 20030N 1998&lt;BR /&gt;4 073902 1992&lt;BR /&gt;4 073902 1993&lt;BR /&gt;6 561232 1995&lt;BR /&gt;8 552848 2002&lt;BR /&gt;8 552848 2004&lt;BR /&gt;8 552848 2007&lt;BR /&gt;8 62945J 1987&lt;BR /&gt;8 62945J 1988&lt;BR /&gt;8 929903 1991&lt;BR /&gt;8 929903 1992&lt;BR /&gt;8 929903 1994&lt;BR /&gt;12 08658U 1995&lt;BR /&gt;12 08658U 1996&lt;BR /&gt;12 08658U 1997&lt;BR /&gt;13 001547 2007&lt;BR /&gt;13 001547 2008&lt;BR /&gt;13 001547 2011&lt;BR /&gt;13 001547 2012&lt;BR /&gt;13 001547 2014&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;By group ID-CUSIP, I want to endow a same value for consecutive years. And, if there is a jump in year, consecutive years from that year on will be endowed another yet same value.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The results I want to obtain are:&amp;nbsp;&lt;/P&gt;&lt;P&gt;ID CUSIP YEAR Newvar&lt;BR /&gt;2 201647 1994&amp;nbsp; &amp;nbsp; &amp;nbsp; 1&lt;BR /&gt;3 20030N 1987&amp;nbsp; &amp;nbsp; &amp;nbsp;1&lt;BR /&gt;3 20030N 1988&amp;nbsp; &amp;nbsp; &amp;nbsp;1&lt;BR /&gt;3 20030N 1989&amp;nbsp; &amp;nbsp; &amp;nbsp;1&lt;BR /&gt;3 20030N 1991&amp;nbsp; &amp;nbsp; &amp;nbsp;2&lt;BR /&gt;3 20030N 1996&amp;nbsp; &amp;nbsp; &amp;nbsp;3&lt;BR /&gt;3 20030N 1997&amp;nbsp; &amp;nbsp; &amp;nbsp;3&lt;BR /&gt;3 20030N 1998&amp;nbsp; &amp;nbsp; &amp;nbsp;3&lt;BR /&gt;4 073902 1992&amp;nbsp; &amp;nbsp; &amp;nbsp;1&lt;BR /&gt;4 073902 1993&amp;nbsp; &amp;nbsp; &amp;nbsp;1&lt;BR /&gt;6 561232 1995&amp;nbsp; &amp;nbsp; &amp;nbsp;1&lt;BR /&gt;8 552848 2002&amp;nbsp; &amp;nbsp; 1&lt;BR /&gt;8 552848 2004&amp;nbsp; &amp;nbsp; 2&lt;BR /&gt;8 552848 2007&amp;nbsp; &amp;nbsp; 3&lt;BR /&gt;8 62945J 1987&amp;nbsp; &amp;nbsp; 1&lt;BR /&gt;8 62945J 1988&amp;nbsp; &amp;nbsp; 1&lt;BR /&gt;8 929903 1991&amp;nbsp; &amp;nbsp; 1&lt;BR /&gt;8 929903 1992&amp;nbsp; &amp;nbsp; 1&lt;BR /&gt;8 929903 1994&amp;nbsp; &amp;nbsp; 2&lt;BR /&gt;12 08658U 1995&amp;nbsp; 1&lt;BR /&gt;12 08658U 1996&amp;nbsp; 1&lt;BR /&gt;12 08658U 1997&amp;nbsp; 1&lt;BR /&gt;13 001547 2007&amp;nbsp; 1&lt;BR /&gt;13 001547 2008&amp;nbsp; 1&lt;BR /&gt;13 001547 2011&amp;nbsp; 2&lt;BR /&gt;13 001547 2012&amp;nbsp; 2&lt;BR /&gt;13 001547 2014&amp;nbsp; 3&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I sincerely thank you all for your wonderful help!&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;KS -,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 25 Feb 2022 19:45:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-provide-a-same-value-for-consecutive-years-and-so-on/m-p/798731#M313998</guid>
      <dc:creator>KS99</dc:creator>
      <dc:date>2022-02-25T19:45:17Z</dc:date>
    </item>
    <item>
      <title>Re: How to provide a same value for consecutive years, and so on?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-provide-a-same-value-for-consecutive-years-and-so-on/m-p/798736#M314001</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
set have;
by id notsorted;
if first.id
then newvar = 1;
if not first.id and lag(year) lt year - 1 then newvar + 1;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 25 Feb 2022 19:51:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-provide-a-same-value-for-consecutive-years-and-so-on/m-p/798736#M314001</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2022-02-25T19:51:14Z</dc:date>
    </item>
    <item>
      <title>Re: How to provide a same value for consecutive years, and so on?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-provide-a-same-value-for-consecutive-years-and-so-on/m-p/798741#M314003</link>
      <description>Thank you. Sir, for helping out.&lt;BR /&gt;It works wonderfully!&lt;BR /&gt;&lt;BR /&gt;KS -,&lt;BR /&gt;</description>
      <pubDate>Fri, 25 Feb 2022 20:11:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-provide-a-same-value-for-consecutive-years-and-so-on/m-p/798741#M314003</guid>
      <dc:creator>KS99</dc:creator>
      <dc:date>2022-02-25T20:11:12Z</dc:date>
    </item>
  </channel>
</rss>

