<?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 recode rows based on certain condition in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/recode-rows-based-on-certain-condition/m-p/692611#M211015</link>
    <description>&lt;P&gt;Hello&lt;/P&gt;&lt;P&gt;I have the following dataset;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data have;&lt;BR /&gt;input id 1. term $8. ca 1.;&lt;BR /&gt;datalines;&lt;BR /&gt;1 199602 1&lt;BR /&gt;1 199603 0&lt;BR /&gt;1 199701 1&lt;BR /&gt;1 199702 1&lt;BR /&gt;1 199703 0&lt;BR /&gt;1 199802 1&lt;BR /&gt;2 200501 1&lt;BR /&gt;2 200502 1&lt;BR /&gt;2 200503 0&lt;BR /&gt;2 200601 0&lt;BR /&gt;2 200602 0&lt;BR /&gt;3 201001 1&lt;BR /&gt;3 201002 1&lt;BR /&gt;3 201003 0&lt;BR /&gt;3 201101 1&lt;BR /&gt;3 201102 1&lt;BR /&gt;;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want it recoded to the following;&lt;/P&gt;&lt;P&gt;data want;&lt;BR /&gt;input id 1. term $8. ca 1.;&lt;BR /&gt;datalines;&lt;BR /&gt;1 199602 1&lt;BR /&gt;1 199603 1&lt;BR /&gt;1 199701 1&lt;BR /&gt;1 199702 1&lt;BR /&gt;1 199703 1&lt;BR /&gt;1 199802 1&lt;BR /&gt;2 200501 1&lt;BR /&gt;2 200502 1&lt;BR /&gt;2 200503 0&lt;BR /&gt;2 200601 0&lt;BR /&gt;2 200602 0&lt;BR /&gt;3 201001 1&lt;BR /&gt;3 201002 1&lt;BR /&gt;3 201003 1&lt;BR /&gt;3 201101 1&lt;BR /&gt;3 201102 1&lt;BR /&gt;;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Basically, i want to recode id=1 and id=3 because both those ids have 1 in the first and 1 in the last term and therefore, if there are zeros in the in-between terms, i want to recode them into one.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please help!&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;ananda&lt;/P&gt;</description>
    <pubDate>Mon, 19 Oct 2020 16:16:00 GMT</pubDate>
    <dc:creator>anandas</dc:creator>
    <dc:date>2020-10-19T16:16:00Z</dc:date>
    <item>
      <title>recode rows based on certain condition</title>
      <link>https://communities.sas.com/t5/SAS-Programming/recode-rows-based-on-certain-condition/m-p/692611#M211015</link>
      <description>&lt;P&gt;Hello&lt;/P&gt;&lt;P&gt;I have the following dataset;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data have;&lt;BR /&gt;input id 1. term $8. ca 1.;&lt;BR /&gt;datalines;&lt;BR /&gt;1 199602 1&lt;BR /&gt;1 199603 0&lt;BR /&gt;1 199701 1&lt;BR /&gt;1 199702 1&lt;BR /&gt;1 199703 0&lt;BR /&gt;1 199802 1&lt;BR /&gt;2 200501 1&lt;BR /&gt;2 200502 1&lt;BR /&gt;2 200503 0&lt;BR /&gt;2 200601 0&lt;BR /&gt;2 200602 0&lt;BR /&gt;3 201001 1&lt;BR /&gt;3 201002 1&lt;BR /&gt;3 201003 0&lt;BR /&gt;3 201101 1&lt;BR /&gt;3 201102 1&lt;BR /&gt;;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want it recoded to the following;&lt;/P&gt;&lt;P&gt;data want;&lt;BR /&gt;input id 1. term $8. ca 1.;&lt;BR /&gt;datalines;&lt;BR /&gt;1 199602 1&lt;BR /&gt;1 199603 1&lt;BR /&gt;1 199701 1&lt;BR /&gt;1 199702 1&lt;BR /&gt;1 199703 1&lt;BR /&gt;1 199802 1&lt;BR /&gt;2 200501 1&lt;BR /&gt;2 200502 1&lt;BR /&gt;2 200503 0&lt;BR /&gt;2 200601 0&lt;BR /&gt;2 200602 0&lt;BR /&gt;3 201001 1&lt;BR /&gt;3 201002 1&lt;BR /&gt;3 201003 1&lt;BR /&gt;3 201101 1&lt;BR /&gt;3 201102 1&lt;BR /&gt;;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Basically, i want to recode id=1 and id=3 because both those ids have 1 in the first and 1 in the last term and therefore, if there are zeros in the in-between terms, i want to recode them into one.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please help!&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;ananda&lt;/P&gt;</description>
      <pubDate>Mon, 19 Oct 2020 16:16:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/recode-rows-based-on-certain-condition/m-p/692611#M211015</guid>
      <dc:creator>anandas</dc:creator>
      <dc:date>2020-10-19T16:16:00Z</dc:date>
    </item>
    <item>
      <title>Re: recode rows based on certain condition</title>
      <link>https://communities.sas.com/t5/SAS-Programming/recode-rows-based-on-certain-condition/m-p/692619#M211017</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
data have;
input id 1. term $8. ca 1.;
datalines;
1 199602 1
1 199603 0
1 199701 1
1 199702 1
1 199703 0
1 199802 1
2 200501 1
2 200502 1
2 200503 0
2 200601 0
2 200602 0
3 201001 1
3 201002 1
3 201003 0
3 201101 1
3 201102 1
;
run;

data want;
 do _n_=1 by 1 until(last.id);
  set have;
  by id;
  if first.id then _n=ca;
 end;
 _n=ca &amp;amp; _n;
 do _n_=1 to _n_;
  set have;
  if _n then ca=_n;
  output;
 end;
 drop _:;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 19 Oct 2020 16:24:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/recode-rows-based-on-certain-condition/m-p/692619#M211017</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2020-10-19T16:24:36Z</dc:date>
    </item>
    <item>
      <title>Re: recode rows based on certain condition</title>
      <link>https://communities.sas.com/t5/SAS-Programming/recode-rows-based-on-certain-condition/m-p/692981#M211225</link>
      <description>&lt;P&gt;Thank you very much for your quick response!&lt;/P&gt;</description>
      <pubDate>Tue, 20 Oct 2020 18:25:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/recode-rows-based-on-certain-condition/m-p/692981#M211225</guid>
      <dc:creator>anandas</dc:creator>
      <dc:date>2020-10-20T18:25:48Z</dc:date>
    </item>
  </channel>
</rss>

