<?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 replace the subsequent rows with a value right above? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-replace-the-subsequent-rows-with-a-value-right-above/m-p/798709#M313990</link>
    <description>Thank you, Sir,&lt;BR /&gt;It works perfectly!&lt;BR /&gt;&lt;BR /&gt;</description>
    <pubDate>Fri, 25 Feb 2022 18:26:18 GMT</pubDate>
    <dc:creator>KS99</dc:creator>
    <dc:date>2022-02-25T18:26:18Z</dc:date>
    <item>
      <title>How to replace the subsequent rows with a value right above?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-replace-the-subsequent-rows-with-a-value-right-above/m-p/798683#M313972</link>
      <description>&lt;P&gt;Hi all,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am really marveled by your expertise and I also sincerely appreciate your help.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have the following dataset:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;ID CUSIP YEAR Diff&lt;BR /&gt;3 20030N 1987 1&lt;BR /&gt;3 20030N 1988 1&lt;BR /&gt;3 20030N 1989 1&lt;BR /&gt;3 20030N 1996 7&lt;BR /&gt;3 20030N 1997 1&lt;BR /&gt;3 20030N 1998 1&lt;BR /&gt;12 08658U 1994 1&lt;BR /&gt;12 08658U 1995 1&lt;BR /&gt;12 08658U 1996 1&lt;BR /&gt;12 08658U 1997 1&lt;BR /&gt;13 001547 2007 1&lt;BR /&gt;13 001547 2008 1&lt;BR /&gt;13 001547 2011 3&lt;BR /&gt;13 001547 2012 1&lt;BR /&gt;16 101137 1996 1&lt;BR /&gt;16 101137 1997 1&lt;BR /&gt;16 101137 1998 1&lt;BR /&gt;16 101137 1999 1&lt;BR /&gt;16 101137 2007 8&lt;BR /&gt;16 101137 2008 1&lt;BR /&gt;16 101137 2009 1&lt;BR /&gt;16 101137 2010 1&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;By group ID-Cusip, the "Diff" starts with 1. Subsequent values of Diff can either be 1's or a value larger than 1. But, even if a value larger than 1 appears, Diff regains 1 after that.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What I want to create is:&amp;nbsp;&lt;/P&gt;&lt;P&gt;By ID-Cusip group, if a value larger than 1 appears, I want to replace all the subsequent 1's with that value (larger than 1).&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So, the data I want would look like this:&amp;nbsp;&lt;/P&gt;&lt;P&gt;ID CUSIP YEAR Diff Newvar&lt;BR /&gt;3 20030N 1987&amp;nbsp; &amp;nbsp; 1&amp;nbsp; &amp;nbsp; &amp;nbsp; 1&lt;BR /&gt;3 20030N 1988&amp;nbsp; &amp;nbsp; 1&amp;nbsp; &amp;nbsp; &amp;nbsp; 1&lt;BR /&gt;3 20030N 1989&amp;nbsp; &amp;nbsp; 1&amp;nbsp; &amp;nbsp; &amp;nbsp; 1&lt;BR /&gt;3 20030N 1996&amp;nbsp; &amp;nbsp; 7&amp;nbsp; &amp;nbsp; &amp;nbsp; 7&lt;BR /&gt;3 20030N 1997&amp;nbsp; &amp;nbsp; 1&amp;nbsp; &amp;nbsp; &amp;nbsp; 7&lt;BR /&gt;3 20030N 1998&amp;nbsp; &amp;nbsp; 1&amp;nbsp; &amp;nbsp; &amp;nbsp; 7&lt;BR /&gt;12 08658U 1994&amp;nbsp; 1&amp;nbsp; &amp;nbsp; &amp;nbsp; 1&lt;BR /&gt;12 08658U 1995&amp;nbsp; 1&amp;nbsp; &amp;nbsp; &amp;nbsp; 1&lt;BR /&gt;12 08658U 1996&amp;nbsp; 1&amp;nbsp; &amp;nbsp; &amp;nbsp; 1&lt;BR /&gt;12 08658U 1997&amp;nbsp; 1&amp;nbsp; &amp;nbsp; &amp;nbsp; 1&lt;BR /&gt;13 001547 2007&amp;nbsp; 1&amp;nbsp; &amp;nbsp; &amp;nbsp; 1&lt;BR /&gt;13 001547 2008&amp;nbsp; 1&amp;nbsp; &amp;nbsp; &amp;nbsp; 1&lt;BR /&gt;13 001547 2011&amp;nbsp; 3&amp;nbsp; &amp;nbsp; &amp;nbsp; 3&lt;BR /&gt;13 001547 2012&amp;nbsp; 1&amp;nbsp; &amp;nbsp; &amp;nbsp;3&lt;BR /&gt;16 101137 1996&amp;nbsp; 1&amp;nbsp; &amp;nbsp; &amp;nbsp;1&lt;BR /&gt;16 101137 1997&amp;nbsp; 1&amp;nbsp; &amp;nbsp; &amp;nbsp;1&lt;BR /&gt;16 101137 1998&amp;nbsp; 1&amp;nbsp; &amp;nbsp; &amp;nbsp;1&lt;BR /&gt;16 101137 1999&amp;nbsp; 1&amp;nbsp; &amp;nbsp; &amp;nbsp;1&lt;BR /&gt;16 101137 2007&amp;nbsp; 8&amp;nbsp; &amp;nbsp; &amp;nbsp;8&lt;BR /&gt;16 101137 2008&amp;nbsp; 1&amp;nbsp; &amp;nbsp; &amp;nbsp;8&lt;BR /&gt;16 101137 2009&amp;nbsp; 1&amp;nbsp; &amp;nbsp; &amp;nbsp;8&lt;BR /&gt;16 101137 2010&amp;nbsp; 1&amp;nbsp; &amp;nbsp; &amp;nbsp;8&amp;nbsp; &amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you in advance!!&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;KS -,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 25 Feb 2022 17:35:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-replace-the-subsequent-rows-with-a-value-right-above/m-p/798683#M313972</guid>
      <dc:creator>KS99</dc:creator>
      <dc:date>2022-02-25T17:35:19Z</dc:date>
    </item>
    <item>
      <title>Re: How to replace the subsequent rows with a value right above?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-replace-the-subsequent-rows-with-a-value-right-above/m-p/798686#M313974</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
    set have;
    by id cusip;
    retain newvar;
    if first.cusip then newvar=1;
    if diff&amp;gt;1 then newvar=diff;
run;
    &lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;This is a good place to use the RETAIN statement. The variable(s) in RETAIN statements keeps the value from the previous row, unless the variable is explicity assigned a new value.&lt;/P&gt;</description>
      <pubDate>Fri, 25 Feb 2022 17:40:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-replace-the-subsequent-rows-with-a-value-right-above/m-p/798686#M313974</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2022-02-25T17:40:46Z</dc:date>
    </item>
    <item>
      <title>Re: How to replace the subsequent rows with a value right above?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-replace-the-subsequent-rows-with-a-value-right-above/m-p/798709#M313990</link>
      <description>Thank you, Sir,&lt;BR /&gt;It works perfectly!&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Fri, 25 Feb 2022 18:26:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-replace-the-subsequent-rows-with-a-value-right-above/m-p/798709#M313990</guid>
      <dc:creator>KS99</dc:creator>
      <dc:date>2022-02-25T18:26:18Z</dc:date>
    </item>
  </channel>
</rss>

