<?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: Select n rows before and after an observation in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Select-n-rows-before-and-after-an-observation/m-p/503056#M134372</link>
    <description>&lt;P&gt;Post your data as SAS data step, not picture.Nobody would like type it for you .&lt;/P&gt;</description>
    <pubDate>Wed, 10 Oct 2018 12:48:48 GMT</pubDate>
    <dc:creator>Ksharp</dc:creator>
    <dc:date>2018-10-10T12:48:48Z</dc:date>
    <item>
      <title>Select n rows before and after an observation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Select-n-rows-before-and-after-an-observation/m-p/503008#M134344</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;Please help in this.&lt;/P&gt;&lt;P&gt;I would like to select 5 rows before and 5 row after a particular observation in a data set. I have tried and searched for the appropriated codes but had no any answer.&amp;nbsp; As the picture below&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-center" image-alt="data.png" style="width: 551px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/23930i0D3D53959B5A50E1/image-size/large?v=v2&amp;amp;px=999" role="button" title="data.png" alt="data.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Basing on 'edate', whenever edate takes a value (for here is 21-APR-2011)&amp;nbsp; I want to take 5 rows before that point and 5 rows after that point. Any suggestion? Thank you.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 10 Oct 2018 08:58:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Select-n-rows-before-and-after-an-observation/m-p/503008#M134344</guid>
      <dc:creator>PhuongNguyen</dc:creator>
      <dc:date>2018-10-10T08:58:11Z</dc:date>
    </item>
    <item>
      <title>Re: Select n rows before and after an observation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Select-n-rows-before-and-after-an-observation/m-p/503016#M134347</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/239467"&gt;@PhuongNguyen&lt;/a&gt;&amp;nbsp;and welcome to the SAS Support Communities!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here is a basic code example for your task:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
set have;
if edate&amp;gt;. then do p=_n_-5 to _n_+5;
  if 1&amp;lt;=p&amp;lt;=n then do;
    set have point=p nobs=n;
    output;
  end;
end;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;You may want to extend the code, for example, in order to exclude the middle observation (and keep only the 5+5, if desired), to avoid duplicate observations if two ranges of +/-5 overlap or to ensure that the 10 or 11 selected observations of a range belong to the same RIC.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;PS: In future posts please provide sample data &lt;EM&gt;in the form of a datastep&lt;/EM&gt; (see &lt;A href="https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-data-AKA-generate/ta-p/258712" target="_blank"&gt;How to convert datasets to data steps&lt;/A&gt;) because it is &lt;EM&gt;very&amp;nbsp;&lt;/EM&gt; difficult, even for SAS, to read data from screenshots.&lt;/P&gt;</description>
      <pubDate>Wed, 10 Oct 2018 09:53:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Select-n-rows-before-and-after-an-observation/m-p/503016#M134347</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2018-10-10T09:53:16Z</dc:date>
    </item>
    <item>
      <title>Re: Select n rows before and after an observation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Select-n-rows-before-and-after-an-observation/m-p/503029#M134357</link>
      <description>&lt;P&gt;The solution suggested by&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/32733"&gt;@FreelanceReinh&lt;/a&gt; looks good, but it can be made a little simpler and safer:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
set have;
if edate&amp;gt;. then do p=max(_n_-5,1) to min(_n_+5,nobs);
  set have point=p nobs=nobs;
  output;
  end;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;- using MAX and MIN functions is the easy way to make sure that you do not try to read non-existing observations.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;One word of warning: if your table contains deleted observations (e.g. because they have been edited with FSEDIT, or somebody used an SQL DELETE FROM statement on it), this will not work correctly. In that case you should copy your input to a temporary table first, like&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data Work.temp;
  set mylib.have;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;so that the table can be accessed with POINT= without problems.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;One question: If you have two valid Edates within 10 rows from each other, do you then want some of the observations output twice?&lt;/P&gt;&lt;P&gt;If not, you may want to do something like this:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
set have;
if edate&amp;gt;. then do p=max(_n_-5,1,p+1) to min(_n_+5,nobs);
  set have point=p nobs=nobs;
  output;
  end;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;so that the same observation is not output twice. The point variable (P) is automatically initialized to 0 and retained.&lt;/P&gt;</description>
      <pubDate>Wed, 10 Oct 2018 10:54:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Select-n-rows-before-and-after-an-observation/m-p/503029#M134357</guid>
      <dc:creator>s_lassen</dc:creator>
      <dc:date>2018-10-10T10:54:35Z</dc:date>
    </item>
    <item>
      <title>Re: Select n rows before and after an observation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Select-n-rows-before-and-after-an-observation/m-p/503050#M134370</link>
      <description>&lt;P&gt;Thanks&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/76464"&gt;@s_lassen&lt;/a&gt;, good points!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I think to avoid duplicates &lt;EM&gt;without skipping observations&lt;/EM&gt; the DO loop should start at&lt;/P&gt;
&lt;PRE&gt;max(_n_-5,1,&lt;FONT color="#FF0000"&gt;p&lt;/FONT&gt;)&lt;/PRE&gt;
&lt;P&gt;because before leaving the previous DO loop p was incremented once more.&lt;/P&gt;</description>
      <pubDate>Wed, 10 Oct 2018 12:29:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Select-n-rows-before-and-after-an-observation/m-p/503050#M134370</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2018-10-10T12:29:51Z</dc:date>
    </item>
    <item>
      <title>Re: Select n rows before and after an observation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Select-n-rows-before-and-after-an-observation/m-p/503056#M134372</link>
      <description>&lt;P&gt;Post your data as SAS data step, not picture.Nobody would like type it for you .&lt;/P&gt;</description>
      <pubDate>Wed, 10 Oct 2018 12:48:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Select-n-rows-before-and-after-an-observation/m-p/503056#M134372</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2018-10-10T12:48:48Z</dc:date>
    </item>
    <item>
      <title>Re: Select n rows before and after an observation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Select-n-rows-before-and-after-an-observation/m-p/503091#M134383</link>
      <description>&lt;P&gt;Many thanks to&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/32733"&gt;@FreelanceReinh&lt;/a&gt;&amp;nbsp;,&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/76464"&gt;@s_lassen&lt;/a&gt;, and&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/18408"&gt;@Ksharp&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The codes work perfect. They are even more than what I expected. I will do datastep next times. Thank you.&lt;/P&gt;</description>
      <pubDate>Wed, 10 Oct 2018 14:05:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Select-n-rows-before-and-after-an-observation/m-p/503091#M134383</guid>
      <dc:creator>PhuongNguyen</dc:creator>
      <dc:date>2018-10-10T14:05:55Z</dc:date>
    </item>
    <item>
      <title>Re: Select n rows before and after an observation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Select-n-rows-before-and-after-an-observation/m-p/503294#M134463</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/32733"&gt;@FreelanceReinh&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;I add 'by RIC' to distinguish among the RIC, and it says the POINT= option is incompatible with the BY statement. Can you help?&lt;/P&gt;</description>
      <pubDate>Thu, 11 Oct 2018 02:24:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Select-n-rows-before-and-after-an-observation/m-p/503294#M134463</guid>
      <dc:creator>PhuongNguyen</dc:creator>
      <dc:date>2018-10-11T02:24:34Z</dc:date>
    </item>
    <item>
      <title>Re: Select n rows before and after an observation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Select-n-rows-before-and-after-an-observation/m-p/503322#M134472</link>
      <description>&lt;P&gt;Sure. The idea is not to use a BY statement, but to compare RIC values:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
set have;
if edate&amp;gt;. then do p=max(_n_-5,1) to min(_n_+5,nobs);
  set have(rename=(ric=ric1)) point=p nobs=nobs;
  if ric=ric1 then output;
end;
drop ric1;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 11 Oct 2018 07:47:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Select-n-rows-before-and-after-an-observation/m-p/503322#M134472</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2018-10-11T07:47:24Z</dc:date>
    </item>
    <item>
      <title>Re: Select n rows before and after an observation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Select-n-rows-before-and-after-an-observation/m-p/503611#M134611</link>
      <description>&lt;P&gt;Thanks so much&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/32733"&gt;@FreelanceReinh&lt;/a&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 12 Oct 2018 01:00:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Select-n-rows-before-and-after-an-observation/m-p/503611#M134611</guid>
      <dc:creator>PhuongNguyen</dc:creator>
      <dc:date>2018-10-12T01:00:22Z</dc:date>
    </item>
    <item>
      <title>Re: Select n rows before and after an observation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Select-n-rows-before-and-after-an-observation/m-p/543132#M150129</link>
      <description>&lt;P&gt;Hello s_lassen,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm using the code you provided here for a similar problem as the one shown here. However, I have to add a statement to make sure that the -5/+5 rows selected still have the same RIC. If the RIC changes after the +3rd obs, SAS should stop and then only select -5/+3. How do I have to adjust your code to make this happen?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you in advance.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;BR&lt;/P&gt;&lt;P&gt;Nici&lt;/P&gt;</description>
      <pubDate>Thu, 14 Mar 2019 13:04:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Select-n-rows-before-and-after-an-observation/m-p/543132#M150129</guid>
      <dc:creator>Nici</dc:creator>
      <dc:date>2019-03-14T13:04:39Z</dc:date>
    </item>
    <item>
      <title>Re: Select n rows before and after an observation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Select-n-rows-before-and-after-an-observation/m-p/589243#M168506</link>
      <description>&lt;P&gt;What if the there is a row before or after 21-APR-2011 and the result shows both rows. But, I want the result to show only 21-APR-2011, so how can I adjusted the codes?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 17 Sep 2019 03:50:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Select-n-rows-before-and-after-an-observation/m-p/589243#M168506</guid>
      <dc:creator>omkana</dc:creator>
      <dc:date>2019-09-17T03:50:17Z</dc:date>
    </item>
    <item>
      <title>Re: Select n rows before and after an observation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Select-n-rows-before-and-after-an-observation/m-p/615767#M180152</link>
      <description>&lt;P&gt;Hello FreelanceReinhard,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have a similar issue but the code provided is not solving it. I want the 2 records before and 2 records bracketing a non missing FIRSTE value. So if there aren't&amp;nbsp; two records before or two records after the non missing value of FIRSTE then all the records for that ID get deleted. In the data below only the records from C and D should be in the final dataset but with the code&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;data have;&lt;BR /&gt;input ID $ AGE RATE TYPE $ FIRSTE;&lt;BR /&gt;datalines ;&lt;BR /&gt;A 14.1 -4.19560471 N .&lt;BR /&gt;A 15.1 -4.186550471 E -4.186550471&lt;BR /&gt;A 15.3 -4.041576561 E .&lt;BR /&gt;A 15.6 -3.984641999 E .&lt;BR /&gt;A 15.8 -4.079763059 E .&lt;BR /&gt;A 16.2 -4.198425079 E .&lt;BR /&gt;B 6.2 -1.118603619 N .&lt;BR /&gt;B 12.25 -3.251832999 N .&lt;BR /&gt;B 12.4 -3.158418124 N .&lt;BR /&gt;B 14.8 -3.739770279 N .&lt;BR /&gt;B 19.1 -3.980687937 E -3.980687937&lt;BR /&gt;B 19.6 -3.901730725 E .&lt;BR /&gt;C 4.3 2.1339735869 N .&lt;BR /&gt;C 5.63 2.1571201461 N .&lt;BR /&gt;C 5.6 2.1571201461 E 2.1571201461&lt;BR /&gt;C 6.1 2.6609995525 E .&lt;BR /&gt;C 6.7 2.1939735869 E .&lt;BR /&gt;C 7.1 2.6991891929 E .&lt;BR /&gt;D 2.4 -0.35998761 N .&lt;BR /&gt;D 2.6 -0.650544267 N .&lt;BR /&gt;D 3.2 -0.817670577 E -0.817670577&lt;BR /&gt;D 3.7 -0.659657975 E .&lt;BR /&gt;D 4.2 -0.370159291 E .&lt;BR /&gt;;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;data want;&lt;BR /&gt;set have;&lt;BR /&gt;if firste&amp;gt;. then do p=max(_n_-2,1,p) to min(_n_+2,nobs);&lt;BR /&gt;set have point=p nobs=nobs;&lt;BR /&gt;output;&lt;BR /&gt;end;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;How can I eliminate records which do not match my condition?&lt;/P&gt;
&lt;P&gt;thanks&lt;/P&gt;</description>
      <pubDate>Tue, 07 Jan 2020 19:33:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Select-n-rows-before-and-after-an-observation/m-p/615767#M180152</guid>
      <dc:creator>Kc2</dc:creator>
      <dc:date>2020-01-07T19:33:41Z</dc:date>
    </item>
    <item>
      <title>Re: Select n rows before and after an observation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Select-n-rows-before-and-after-an-observation/m-p/615773#M180155</link>
      <description>&lt;P&gt;I was able to get to my desired results by adding another step&lt;/P&gt;
&lt;P&gt;proc sql;&lt;BR /&gt;create table final as&lt;BR /&gt;select *, count(id) as cnt&lt;BR /&gt;from want&lt;BR /&gt;group by id&lt;BR /&gt;having calculated cnt &amp;gt;=5&lt;BR /&gt;;&lt;BR /&gt;quit;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Does anyone know if it is possible to do it in one step?&lt;/P&gt;</description>
      <pubDate>Tue, 07 Jan 2020 19:52:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Select-n-rows-before-and-after-an-observation/m-p/615773#M180155</guid>
      <dc:creator>Kc2</dc:creator>
      <dc:date>2020-01-07T19:52:23Z</dc:date>
    </item>
    <item>
      <title>Re: Select n rows before and after an observation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Select-n-rows-before-and-after-an-observation/m-p/615975#M180250</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;has anyone had an issue with the code:&lt;/P&gt;
&lt;P&gt;if firste&amp;gt;. then do p=max(_n_-2,1,p) to min(_n_+2,nobs);&lt;BR /&gt;set have point=p nobs=nobs;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am having issue with the record ID E.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data have;&lt;BR /&gt;input ID $ AGE RATE TYPE $ FIRSTE;&lt;BR /&gt;datalines ;&lt;BR /&gt;A 14.1 -4.19560471 N .&lt;BR /&gt;A 15.1 -4.186550471 E -4.186550471&lt;BR /&gt;A 15.3 -4.041576561 E .&lt;BR /&gt;A 15.6 -3.984641999 E .&lt;BR /&gt;A 15.8 -4.079763059 E .&lt;BR /&gt;A 16.2 -4.198425079 E .&lt;BR /&gt;B 6.2 -1.118603619 N .&lt;BR /&gt;B 12.25 -3.251832999 N .&lt;BR /&gt;B 12.4 -3.158418124 N .&lt;BR /&gt;B 14.8 -3.739770279 N .&lt;BR /&gt;B 19.1 -3.980687937 E -3.980687937&lt;BR /&gt;B 19.6 -3.901730725 E .&lt;BR /&gt;C 4.3 2.1339735869 N .&lt;BR /&gt;C 5.4 2.1571201461 N .&lt;BR /&gt;C 5.6 2.1571201461 E 2.1571201461&lt;BR /&gt;C 6.1 2.6609995525 E .&lt;BR /&gt;C 6.7 2.1939735869 E .&lt;BR /&gt;C 7.1 2.6991891929 E .&lt;BR /&gt;D 2.4 -0.35998761 N .&lt;BR /&gt;D 2.6 -0.650544267 N .&lt;BR /&gt;D 3.2 -0.817670577 E -0.817670577&lt;BR /&gt;D 3.7 -0.659657975 E .&lt;BR /&gt;D 4.2 -0.370159291 E .&lt;BR /&gt;E 15.6 -3.679862707 N .&lt;BR /&gt;E 16.4 -3.248757219 E -3.248757219&lt;BR /&gt;E 16.9 -3.128994865 E .&lt;BR /&gt;E 17.4 -2.892552007 E .&lt;BR /&gt;E 17.9 -2.741253675 E .&lt;BR /&gt;E 18.4 -2.591966458 E .&lt;BR /&gt;E 19.3 -2.42630517 E .&lt;BR /&gt;;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data want;&lt;BR /&gt;set have;&lt;BR /&gt;if firste&amp;gt;. then do p=max(_n_-2,1,p) to min(_n_+2,nobs);&lt;BR /&gt;set have point=p nobs=nobs;&lt;BR /&gt;output;&lt;BR /&gt;end;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;When I run the code on a subset of my dataset , I get the right records.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;E 16.4 -3.248757219 E -3.248757219&lt;BR /&gt;E 16.9 -3.128994865 E .&lt;BR /&gt;E 17.4 -2.892552007 E .&lt;BR /&gt;E 17.9 -2.741253675 E .&lt;/P&gt;
&lt;P&gt;But when I run the code on the whole set , for ID E I get one extra observation&lt;/P&gt;
&lt;P&gt;E 16.4 -3.248757219 E -3.248757219&lt;BR /&gt;E 16.9 -3.128994865 E .&lt;BR /&gt;E 17.4 -2.892552007 E .&lt;BR /&gt;E 17.9 -2.741253675 E .&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000FF"&gt;E 19.3 -2.42630517 E .&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000000"&gt;I am not able to figure out why this extra row gets added. It is only happening&amp;nbsp; for this one record when the full dataset is used (1000 records)&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000000"&gt;Anyone has a suggestion?&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000000"&gt;Thanks&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 08 Jan 2020 16:09:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Select-n-rows-before-and-after-an-observation/m-p/615975#M180250</guid>
      <dc:creator>Kc2</dc:creator>
      <dc:date>2020-01-08T16:09:46Z</dc:date>
    </item>
  </channel>
</rss>

