<?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 Data are not missing at least two consecutive years in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Data-are-not-missing-at-least-two-consecutive-years/m-p/885399#M82844</link>
    <description>&lt;P&gt;Hi, all experts.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have a sample selection criterion which is data are not missing at least two consecutive years.&lt;/P&gt;
&lt;P&gt;I have a sample below.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
  input Panelist Year othervars;
  cards;
1          2017 1
1          2019 1
1          2020 1
2          2017 1
2          2020 1
3          2018 1
3          2020 1
;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I want to be like the code below.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
  input Panelist Year othervars;
  cards;
1          2017 1
1          2019 1
1          2020 1
3          2018 1
3          2020 1
;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Does anyone know how to solve this problem?&lt;/P&gt;
&lt;P&gt;Thanks in advance.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 19 Jul 2023 05:52:17 GMT</pubDate>
    <dc:creator>shawnchen0321</dc:creator>
    <dc:date>2023-07-19T05:52:17Z</dc:date>
    <item>
      <title>Data are not missing at least two consecutive years</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Data-are-not-missing-at-least-two-consecutive-years/m-p/885399#M82844</link>
      <description>&lt;P&gt;Hi, all experts.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have a sample selection criterion which is data are not missing at least two consecutive years.&lt;/P&gt;
&lt;P&gt;I have a sample below.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
  input Panelist Year othervars;
  cards;
1          2017 1
1          2019 1
1          2020 1
2          2017 1
2          2020 1
3          2018 1
3          2020 1
;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I want to be like the code below.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
  input Panelist Year othervars;
  cards;
1          2017 1
1          2019 1
1          2020 1
3          2018 1
3          2020 1
;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Does anyone know how to solve this problem?&lt;/P&gt;
&lt;P&gt;Thanks in advance.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 19 Jul 2023 05:52:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Data-are-not-missing-at-least-two-consecutive-years/m-p/885399#M82844</guid>
      <dc:creator>shawnchen0321</dc:creator>
      <dc:date>2023-07-19T05:52:17Z</dc:date>
    </item>
    <item>
      <title>Re: Data are not missing at least two consecutive years</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Data-are-not-missing-at-least-two-consecutive-years/m-p/885435#M82845</link>
      <description>&lt;P&gt;You have to pass through each panelist twice - once to find gaps, and the second time to reread and output those with no two-year gaps:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
data want (drop=_:);
  set have (in=firstpass)  have (in=secondpass);
  by panelist;

  _gap_found + (firstpass=1 and dif(year)&amp;gt;2);
  if first.panelist then _gap_found=0;

  if secondpass and _gap_found=0;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This assumes that the data are sorted by panelist/year.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Editted note: the DIF(x) function is the result of&amp;nbsp; &amp;nbsp;x-LAG(x), except it doesn't generate a "missing values were generated ..." note for the first observation.&lt;/P&gt;</description>
      <pubDate>Wed, 19 Jul 2023 12:33:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Data-are-not-missing-at-least-two-consecutive-years/m-p/885435#M82845</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2023-07-19T12:33:16Z</dc:date>
    </item>
    <item>
      <title>Re: Data are not missing at least two consecutive years</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Data-are-not-missing-at-least-two-consecutive-years/m-p/885448#M82846</link>
      <description>&lt;P&gt;It can work. Thanks a lot.&lt;/P&gt;</description>
      <pubDate>Wed, 19 Jul 2023 13:13:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Data-are-not-missing-at-least-two-consecutive-years/m-p/885448#M82846</guid>
      <dc:creator>shawnchen0321</dc:creator>
      <dc:date>2023-07-19T13:13:18Z</dc:date>
    </item>
  </channel>
</rss>

