<?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: How to move to next record if a condition is satisfied? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-move-to-next-record-if-a-condition-is-satisfied/m-p/353226#M82438</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks for the details.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It is working as expected.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Regards,&lt;/P&gt;
&lt;P&gt;Sheeba&lt;/P&gt;</description>
    <pubDate>Tue, 25 Apr 2017 15:19:22 GMT</pubDate>
    <dc:creator>Sheeba</dc:creator>
    <dc:date>2017-04-25T15:19:22Z</dc:date>
    <item>
      <title>How to move to next record if a condition is satisfied?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-move-to-next-record-if-a-condition-is-satisfied/m-p/353001#M82359</link>
      <description>&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;Hi,&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am using the below code to match records from two to three. I am setting a flag to zero (matchingrecordfound=0) . For each row in dataset &lt;STRONG&gt;two&lt;/STRONG&gt; , I am looping through the dataset &lt;STRONG&gt;three &lt;/STRONG&gt;and do the processing only if matchingrecordfound is less than 2 (capturing only two matches in the output dataset). &amp;nbsp;Is there any way I can avoid looping through the &amp;nbsp;&lt;STRONG&gt;three &lt;/STRONG&gt;if matchingrecordfound is equal to 2 for a particular record in &lt;STRONG&gt;two?&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;data&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; two;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;input&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; state $ column1;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;datalines&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;OH 123&lt;/P&gt;
&lt;P&gt;TX 234&lt;/P&gt;
&lt;P&gt;;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;data&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; three;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;input&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; state $ column2 column3;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;datalines&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;OH 111 222&lt;/P&gt;
&lt;P&gt;CA 333 444&lt;/P&gt;
&lt;P&gt;OH 123 555&lt;/P&gt;
&lt;P&gt;OH 123 666&lt;/P&gt;
&lt;P&gt;OH 123 777&lt;/P&gt;
&lt;P&gt;OH 123 888&lt;/P&gt;
&lt;P&gt;;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;data&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; temp1 temp2;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt; matchingrecordfound=&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;0&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;set&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; two;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;/* if matchingrecordfound=2 for a record in two i need to move to next record */&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;do&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; i = &lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;1&lt;/FONT&gt;&lt;/STRONG&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;to&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; nobs;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;set&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; three &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;point&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;=i &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;nobs&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;=nobs;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;if&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; matchingrecordfound &amp;lt; &lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;2&lt;/FONT&gt;&lt;/STRONG&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;then&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;do&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;if&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; column1=column2 &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;then&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;do&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt; Matchingrecordfound+&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;1&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;output&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; temp1;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;end&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;else&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;do&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;output&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; temp2;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;end&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;end&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;end&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;Thanks in advance&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;Regards,&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;Sheeba &lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 24 Apr 2017 20:04:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-move-to-next-record-if-a-condition-is-satisfied/m-p/353001#M82359</guid>
      <dc:creator>Sheeba</dc:creator>
      <dc:date>2017-04-24T20:04:42Z</dc:date>
    </item>
    <item>
      <title>Re: How to move to next record if a condition is satisfied?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-move-to-next-record-if-a-condition-is-satisfied/m-p/353004#M82361</link>
      <description>&lt;P&gt;A few observations.&amp;nbsp; First, if&amp;nbsp; you were to accomplish what you ask for, the number of observations in the data set TEMP2&amp;nbsp;would change.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Second, why output anything at all to TEMP2?&amp;nbsp; Why not just output the observations that match to TEMP1 and skip creating TEMP2 entirely?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Third, to answer&amp;nbsp; your original question, it's fairly easy:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New"&gt;do&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; i = &lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;1&lt;/FONT&gt;&lt;/STRONG&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;to&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; nobs until(matchrecordfound=2);&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Finally, SAS has tools that support detection of matches/nonmatches using fairly straightforward code.&amp;nbsp; Try it this way.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;data&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; two;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;input&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; state $ column1;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;datalines&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;OH 123&lt;/P&gt;
&lt;P&gt;TX 234&lt;/P&gt;
&lt;P&gt;;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;&amp;nbsp;&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;data&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; three;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;input&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; state $ column&lt;STRONG&gt;&lt;FONT color="#ff0000"&gt;1&lt;/FONT&gt;&lt;/STRONG&gt; column3;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;datalines&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;OH 111 222&lt;/P&gt;
&lt;P&gt;CA 333 444&lt;/P&gt;
&lt;P&gt;OH 123 555&lt;/P&gt;
&lt;P&gt;OH 123 666&lt;/P&gt;
&lt;P&gt;OH 123 777&lt;/P&gt;
&lt;P&gt;OH 123 888&lt;/P&gt;
&lt;P&gt;;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;&amp;nbsp;&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;proc sort data=two;&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;by state column1;&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;run;&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;proc sort data=three;&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;by state column1;&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;run;&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;data&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; two_matches;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;merge two (in=in2) three (in=in3);&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;by state column1;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;if in2 and in3;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New"&gt;if first.column1 then matching_record=1;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;else matching_record + 1;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;if matching_record &amp;lt;= 2;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;run;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Note that the variable name changed to COLUMN1 on one of the INPUT statements.&amp;nbsp; As long as you are allowed to sort your data sets, this would be an easy way to match.&lt;/P&gt;</description>
      <pubDate>Mon, 24 Apr 2017 20:29:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-move-to-next-record-if-a-condition-is-satisfied/m-p/353004#M82361</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2017-04-24T20:29:27Z</dc:date>
    </item>
    <item>
      <title>Re: How to move to next record if a condition is satisfied?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-move-to-next-record-if-a-condition-is-satisfied/m-p/353010#M82364</link>
      <description>&lt;P&gt;Hi Astounding,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks a lot for &amp;nbsp;for the detailed reply.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Actually I am using this approach for join due to the nature of data. When i try to join the&amp;nbsp; datasets based on column1, it results in many to many merge and when we use merge step for joining, it results in the loss of data.. The data which i put in the example is a sample and does not illustrate the many to many join .&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am creating two outputs - temp1 for matches and temp2 for notmatches. the requirement is to capture both matches and notmatches and finally combine everything into a single dataset. There are cases when a single record from dataset two falls in both&amp;nbsp;temp1 and temp2 but I am taking care of this in the next step by deleting those obersevations from temp2 which are already present in temp1. so by the end of this step i get matches and notmatches.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks again,&lt;/P&gt;
&lt;P&gt;Regards,&lt;/P&gt;
&lt;P&gt;Sheeba&lt;/P&gt;</description>
      <pubDate>Mon, 24 Apr 2017 21:05:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-move-to-next-record-if-a-condition-is-satisfied/m-p/353010#M82364</guid>
      <dc:creator>Sheeba</dc:creator>
      <dc:date>2017-04-24T21:05:20Z</dc:date>
    </item>
    <item>
      <title>Re: How to move to next record if a condition is satisfied?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-move-to-next-record-if-a-condition-is-satisfied/m-p/353013#M82366</link>
      <description>&lt;P&gt;There's more than one way to interpret the final goal here.&amp;nbsp; It would be helpful to take a data set with duplicates:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;OH 123&lt;/P&gt;
&lt;P&gt;OH 123&lt;/P&gt;
&lt;P&gt;TX 234&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Illustrate (using the same THREE data set) what you would like the very final outcome to be.&amp;nbsp; Intermediate data sets are not required, just the very final result.&lt;/P&gt;</description>
      <pubDate>Mon, 24 Apr 2017 21:19:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-move-to-next-record-if-a-condition-is-satisfied/m-p/353013#M82366</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2017-04-24T21:19:03Z</dc:date>
    </item>
    <item>
      <title>Re: How to move to next record if a condition is satisfied?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-move-to-next-record-if-a-condition-is-satisfied/m-p/353019#M82369</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Two&lt;/P&gt;
&lt;P&gt;state column1 id&lt;/P&gt;
&lt;P&gt;OH&amp;nbsp;&amp;nbsp; 123&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&lt;/P&gt;
&lt;P&gt;OH&amp;nbsp;&amp;nbsp; 123&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 2&lt;/P&gt;
&lt;P&gt;TX&amp;nbsp;&amp;nbsp;&amp;nbsp; 234&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 3&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;state col2 col3&lt;BR /&gt;OH&amp;nbsp;&amp;nbsp; 111 222&lt;/P&gt;
&lt;P&gt;CA&amp;nbsp;&amp;nbsp; 333 444&lt;/P&gt;
&lt;P&gt;OH&amp;nbsp;&amp;nbsp; 123 555&lt;/P&gt;
&lt;P&gt;OH&amp;nbsp;&amp;nbsp; 123 666&lt;/P&gt;
&lt;P&gt;OH&amp;nbsp;&amp;nbsp; 123 777&lt;/P&gt;
&lt;P&gt;OH&amp;nbsp;&amp;nbsp; 123 888&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Final output&lt;/P&gt;
&lt;P&gt;OH 123 555 1&lt;BR /&gt;OH 123 666 1&lt;BR /&gt;OH 123 555 2&lt;BR /&gt;OH 123 666 2&lt;BR /&gt;TX&amp;nbsp; 234 .&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 3&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The code which i have posted here as a part of question does not catch the last record .&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;data&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; temp1 temp2;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt; matchingrecordfound=&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;0&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;set&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; two;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;do&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; i = &lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;1&lt;/FONT&gt;&lt;/STRONG&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;to&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; nobs &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;until&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;(matchingrecordfound=&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;2&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;);;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;set&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; three &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;point&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;=i &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;nobs&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;=nobs;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;if&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; matchingrecordfound &amp;lt; &lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;2&lt;/FONT&gt;&lt;/STRONG&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;then&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;do&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;/* the below if condition is dynamic . created at the time of join and it may vary depending on data*/&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;if&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; column1=column2 &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;then&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;do&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt; Matchingrecordfound+&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;1&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;output&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; temp1;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;end&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;else&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;do&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;output&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; temp2;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;end&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;end&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;end&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Regards,&lt;/P&gt;
&lt;P&gt;Sheeba&lt;/P&gt;</description>
      <pubDate>Mon, 24 Apr 2017 21:41:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-move-to-next-record-if-a-condition-is-satisfied/m-p/353019#M82369</guid>
      <dc:creator>Sheeba</dc:creator>
      <dc:date>2017-04-24T21:41:03Z</dc:date>
    </item>
    <item>
      <title>Re: How to move to next record if a condition is satisfied?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-move-to-next-record-if-a-condition-is-satisfied/m-p/353035#M82376</link>
      <description>&lt;P&gt;OK, just a few changes can get you the final output directly. &amp;nbsp;The code is untested but looks like it should work:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3" color="#000080"&gt;&lt;STRONG&gt;data&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&amp;nbsp;final_output;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;matchingrecordfound=&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT face="Courier New" size="3" color="#008080"&gt;0&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3" color="#0000ff"&gt;set&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; two;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3" color="#0000ff"&gt;do&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; i = &lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT face="Courier New" size="3" color="#008080"&gt;1&lt;/FONT&gt;&lt;/STRONG&gt; &lt;FONT face="Courier New" size="3" color="#0000ff"&gt;to&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; nobs &lt;/FONT&gt;&lt;FONT face="Courier New" size="3" color="#0000ff"&gt;until&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;(matchingrecordfound=&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT face="Courier New" size="3" color="#008080"&gt;2&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;);&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3" color="#0000ff"&gt;set&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; three (rename=(state=state2))&amp;nbsp;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3" color="#0000ff"&gt;point&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;=i &lt;/FONT&gt;&lt;FONT face="Courier New" size="3" color="#0000ff"&gt;nobs&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;=nobs;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3" color="#0000ff"&gt;if&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&amp;nbsp;state=state2 and column1=column2 &lt;/FONT&gt;&lt;FONT face="Courier New" size="3" color="#0000ff"&gt;then&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3" color="#0000ff"&gt;do&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;&amp;nbsp; &amp;nbsp;Matchingrecordfound+&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT face="Courier New" size="3" color="#008080"&gt;1&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3" color="#0000ff"&gt;&amp;nbsp; &amp;nbsp;output&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3" color="#0000ff"&gt;end&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3" color="#0000ff"&gt;end&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;if Matchingrecordfound=0 then do;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;&amp;nbsp; &amp;nbsp;column2 = column1;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;&amp;nbsp; &amp;nbsp;column3 = .;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;&amp;nbsp; &amp;nbsp;output;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;run;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;keep state column2 column3 id;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3" color="#000080"&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 24 Apr 2017 22:54:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-move-to-next-record-if-a-condition-is-satisfied/m-p/353035#M82376</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2017-04-24T22:54:14Z</dc:date>
    </item>
    <item>
      <title>Re: How to move to next record if a condition is satisfied?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-move-to-next-record-if-a-condition-is-satisfied/m-p/353226#M82438</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks for the details.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It is working as expected.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Regards,&lt;/P&gt;
&lt;P&gt;Sheeba&lt;/P&gt;</description>
      <pubDate>Tue, 25 Apr 2017 15:19:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-move-to-next-record-if-a-condition-is-satisfied/m-p/353226#M82438</guid>
      <dc:creator>Sheeba</dc:creator>
      <dc:date>2017-04-25T15:19:22Z</dc:date>
    </item>
  </channel>
</rss>

