<?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: do sth only if conditions in the next row are met in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/do-sth-only-if-conditions-in-the-next-row-are-met/m-p/788638#M252192</link>
    <description>&lt;P&gt;Look up the POINT= option on the SET statement. You can have one SET statement (with the POINT= option) that reads ahead and one ordinary SET statement that reads the current row to process. There are other ways too. Be sure to not use POINT= to try to read beyond the data.&lt;/P&gt;</description>
    <pubDate>Thu, 06 Jan 2022 12:06:47 GMT</pubDate>
    <dc:creator>WarrenKuhfeld</dc:creator>
    <dc:date>2022-01-06T12:06:47Z</dc:date>
    <item>
      <title>do sth only if conditions in the next row are met</title>
      <link>https://communities.sas.com/t5/SAS-Programming/do-sth-only-if-conditions-in-the-next-row-are-met/m-p/788635#M252189</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I will try it as simply as possible at first...&lt;/P&gt;&lt;P&gt;I have this dataset:&lt;/P&gt;&lt;P&gt;group&amp;nbsp; &amp;nbsp;n_animals&amp;nbsp; age_difference&lt;/P&gt;&lt;P&gt;1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 8&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;2&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 45&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;2&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/P&gt;&lt;P&gt;4&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 19&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;1&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;And I would like to programme this:&amp;nbsp;if group=1 and n_animals&amp;lt;30 then create variable g2 as group+1 &lt;EM&gt;“but only when the next group (group=1+1) has age difference &amp;lt; 2”.&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The part in quotes is something I cannot figure out. I would really appreciate if the syntax stayed this way so I do not have to start from scratch.&lt;/P&gt;</description>
      <pubDate>Thu, 06 Jan 2022 11:57:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/do-sth-only-if-conditions-in-the-next-row-are-met/m-p/788635#M252189</guid>
      <dc:creator>opiczak</dc:creator>
      <dc:date>2022-01-06T11:57:35Z</dc:date>
    </item>
    <item>
      <title>Re: do sth only if conditions in the next row are met</title>
      <link>https://communities.sas.com/t5/SAS-Programming/do-sth-only-if-conditions-in-the-next-row-are-met/m-p/788638#M252192</link>
      <description>&lt;P&gt;Look up the POINT= option on the SET statement. You can have one SET statement (with the POINT= option) that reads ahead and one ordinary SET statement that reads the current row to process. There are other ways too. Be sure to not use POINT= to try to read beyond the data.&lt;/P&gt;</description>
      <pubDate>Thu, 06 Jan 2022 12:06:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/do-sth-only-if-conditions-in-the-next-row-are-met/m-p/788638#M252192</guid>
      <dc:creator>WarrenKuhfeld</dc:creator>
      <dc:date>2022-01-06T12:06:47Z</dc:date>
    </item>
    <item>
      <title>Re: do sth only if conditions in the next row are met</title>
      <link>https://communities.sas.com/t5/SAS-Programming/do-sth-only-if-conditions-in-the-next-row-are-met/m-p/788644#M252193</link>
      <description>&lt;P&gt;Assuming I understand your question.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;data have;
input group   n_animals  age_difference;
cards;
1          8                 1                        
2          45               2                     
4          19               1
;


data want;
merge have have(keep=age_difference rename=(age_difference=_age_difference) firstobs=2);
if group=1 and n_animals&amp;lt;30 and  _age_difference&amp;lt; 2 then g2=group+1;
drop _age_difference;
run;&lt;/PRE&gt;</description>
      <pubDate>Thu, 06 Jan 2022 12:28:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/do-sth-only-if-conditions-in-the-next-row-are-met/m-p/788644#M252193</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2022-01-06T12:28:21Z</dc:date>
    </item>
    <item>
      <title>Re: do sth only if conditions in the next row are met</title>
      <link>https://communities.sas.com/t5/SAS-Programming/do-sth-only-if-conditions-in-the-next-row-are-met/m-p/788648#M252195</link>
      <description>Thank you very much! I think this can work. I would like to mark your reply as a solution, but apparently there can be only one (?). So I hope you do not mind.</description>
      <pubDate>Thu, 06 Jan 2022 12:44:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/do-sth-only-if-conditions-in-the-next-row-are-met/m-p/788648#M252195</guid>
      <dc:creator>opiczak</dc:creator>
      <dc:date>2022-01-06T12:44:29Z</dc:date>
    </item>
    <item>
      <title>Re: do sth only if conditions in the next row are met</title>
      <link>https://communities.sas.com/t5/SAS-Programming/do-sth-only-if-conditions-in-the-next-row-are-met/m-p/788649#M252196</link>
      <description>Thank you, Warren. I quickly went through some guide and I am pretty sure this can solve my problem. Have a nice day.</description>
      <pubDate>Thu, 06 Jan 2022 12:46:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/do-sth-only-if-conditions-in-the-next-row-are-met/m-p/788649#M252196</guid>
      <dc:creator>opiczak</dc:creator>
      <dc:date>2022-01-06T12:46:19Z</dc:date>
    </item>
    <item>
      <title>Re: do sth only if conditions in the next row are met</title>
      <link>https://communities.sas.com/t5/SAS-Programming/do-sth-only-if-conditions-in-the-next-row-are-met/m-p/788826#M252322</link>
      <description>I do not mind and do not care . &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;</description>
      <pubDate>Fri, 07 Jan 2022 11:57:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/do-sth-only-if-conditions-in-the-next-row-are-met/m-p/788826#M252322</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2022-01-07T11:57:37Z</dc:date>
    </item>
  </channel>
</rss>

