<?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 manipulation using previous and next in SAS Data Management</title>
    <link>https://communities.sas.com/t5/SAS-Data-Management/data-manipulation-using-previous-and-next/m-p/365516#M11022</link>
    <description>&lt;P&gt;id gap&lt;BR /&gt;001 0&lt;BR /&gt;001 1&lt;BR /&gt;001 2&lt;BR /&gt;002 0&lt;BR /&gt;002 2&lt;BR /&gt;002 1&lt;BR /&gt;003 0&lt;BR /&gt;003 1&lt;BR /&gt;003 1&lt;BR /&gt;004 0&lt;BR /&gt;004 2&lt;BR /&gt;004 2&lt;BR /&gt;005 0&lt;BR /&gt;;&lt;/P&gt;
&lt;P&gt;Once gap is a 1 in any position for a particular id, gap=1 for all visit for that particular id.&lt;/P&gt;
&lt;P&gt;if gap is 0, 2, without one, then for that id gap=2 for both position ie, we change the 0 to 2.&lt;/P&gt;
&lt;P&gt;that above data will Change to:&lt;/P&gt;
&lt;P&gt;id gap&lt;BR /&gt;&lt;STRONG&gt;001 1&lt;/STRONG&gt;&lt;BR /&gt;001 1&lt;BR /&gt;&lt;STRONG&gt;001 1&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;002 1&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;002 1&lt;/STRONG&gt;&lt;BR /&gt;002 1&lt;BR /&gt;&lt;STRONG&gt;003 1&lt;/STRONG&gt;&lt;BR /&gt;003 1&lt;BR /&gt;003 1&lt;BR /&gt;&lt;STRONG&gt;004 2&lt;/STRONG&gt;&lt;BR /&gt;004 2&lt;BR /&gt;004 2&lt;BR /&gt;005 0&lt;BR /&gt;;&lt;/P&gt;</description>
    <pubDate>Thu, 08 Jun 2017 20:45:02 GMT</pubDate>
    <dc:creator>desireatem</dc:creator>
    <dc:date>2017-06-08T20:45:02Z</dc:date>
    <item>
      <title>data manipulation using previous and next</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/data-manipulation-using-previous-and-next/m-p/365516#M11022</link>
      <description>&lt;P&gt;id gap&lt;BR /&gt;001 0&lt;BR /&gt;001 1&lt;BR /&gt;001 2&lt;BR /&gt;002 0&lt;BR /&gt;002 2&lt;BR /&gt;002 1&lt;BR /&gt;003 0&lt;BR /&gt;003 1&lt;BR /&gt;003 1&lt;BR /&gt;004 0&lt;BR /&gt;004 2&lt;BR /&gt;004 2&lt;BR /&gt;005 0&lt;BR /&gt;;&lt;/P&gt;
&lt;P&gt;Once gap is a 1 in any position for a particular id, gap=1 for all visit for that particular id.&lt;/P&gt;
&lt;P&gt;if gap is 0, 2, without one, then for that id gap=2 for both position ie, we change the 0 to 2.&lt;/P&gt;
&lt;P&gt;that above data will Change to:&lt;/P&gt;
&lt;P&gt;id gap&lt;BR /&gt;&lt;STRONG&gt;001 1&lt;/STRONG&gt;&lt;BR /&gt;001 1&lt;BR /&gt;&lt;STRONG&gt;001 1&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;002 1&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;002 1&lt;/STRONG&gt;&lt;BR /&gt;002 1&lt;BR /&gt;&lt;STRONG&gt;003 1&lt;/STRONG&gt;&lt;BR /&gt;003 1&lt;BR /&gt;003 1&lt;BR /&gt;&lt;STRONG&gt;004 2&lt;/STRONG&gt;&lt;BR /&gt;004 2&lt;BR /&gt;004 2&lt;BR /&gt;005 0&lt;BR /&gt;;&lt;/P&gt;</description>
      <pubDate>Thu, 08 Jun 2017 20:45:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/data-manipulation-using-previous-and-next/m-p/365516#M11022</guid>
      <dc:creator>desireatem</dc:creator>
      <dc:date>2017-06-08T20:45:02Z</dc:date>
    </item>
    <item>
      <title>Re: data manipulation using previous and next</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/data-manipulation-using-previous-and-next/m-p/365534#M11023</link>
      <description>&lt;P&gt;This probably comes close enough:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data want;&lt;/P&gt;
&lt;P&gt;do until (last.id);&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; set have;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; by id;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; if gap=1 then new_gap=1;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; else if gap=2 and new_gap=. then new_gap=2;&lt;/P&gt;
&lt;P&gt;end;&lt;/P&gt;
&lt;P&gt;do until (last.id);&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; set have;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; by id;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; if new_gap &amp;gt; . then gap = new_gap;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; output;&lt;/P&gt;
&lt;P&gt;end;&lt;/P&gt;
&lt;P&gt;drop new_gap;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;When I say comes "close enough", the program doesn't check for 0 and 2.&amp;nbsp; It checks for 2 (but without 1).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The top loop reads all the observations for an ID, looking at the GAP values.&amp;nbsp; Then the bottom loop re-reads the same observations, changes GAP, and outputs.&lt;/P&gt;</description>
      <pubDate>Thu, 08 Jun 2017 21:38:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/data-manipulation-using-previous-and-next/m-p/365534#M11023</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2017-06-08T21:38:50Z</dc:date>
    </item>
    <item>
      <title>Re: data manipulation using previous and next</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/data-manipulation-using-previous-and-next/m-p/365583#M11024</link>
      <description>&lt;P&gt;Thank you very much!!!!&lt;/P&gt;</description>
      <pubDate>Fri, 09 Jun 2017 02:45:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/data-manipulation-using-previous-and-next/m-p/365583#M11024</guid>
      <dc:creator>desireatem</dc:creator>
      <dc:date>2017-06-09T02:45:31Z</dc:date>
    </item>
  </channel>
</rss>

