<?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: Retain the last data until the non empty row in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Retain-the-last-data-until-the-non-empty-row/m-p/919683#M362253</link>
    <description>&lt;P&gt;Do selective updating of mt_corr, then selective updating of mt_2.&amp;nbsp; This program is untested, but it should fill in the yellow cells in your data:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
data matable3;
  set matable2;
  by numero code2;
  retain mt_corr;
  if first.code2 then mt_corr=.;
  if mt_2^=. then mt_corr=mt_2;
  else mt_2=mt_corr;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sun, 10 Mar 2024 16:47:44 GMT</pubDate>
    <dc:creator>mkeintz</dc:creator>
    <dc:date>2024-03-10T16:47:44Z</dc:date>
    <item>
      <title>Retain the last data until the non empty row</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Retain-the-last-data-until-the-non-empty-row/m-p/919682#M362252</link>
      <description>&lt;P&gt;Hello Experts,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I would like to replace the empty rows with the last known data and create the column&amp;nbsp;MT_CORR, but my code doesn't work.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;My code is :&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Data matable3;
	set matable2;
	by Numero Code2;
	if first.Numero and first.Code then 
	MT_CORR=MT_2;
    retain MT_CORR;
	;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;I have joined the file.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="SASdevAnneMarie_0-1710088496194.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/94542i01A936E753D57A03/image-size/medium?v=v2&amp;amp;px=400" role="button" title="SASdevAnneMarie_0-1710088496194.png" alt="SASdevAnneMarie_0-1710088496194.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;Thank you for you help.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 10 Mar 2024 16:36:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Retain-the-last-data-until-the-non-empty-row/m-p/919682#M362252</guid>
      <dc:creator>SASdevAnneMarie</dc:creator>
      <dc:date>2024-03-10T16:36:18Z</dc:date>
    </item>
    <item>
      <title>Re: Retain the last data until the non empty row</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Retain-the-last-data-until-the-non-empty-row/m-p/919683#M362253</link>
      <description>&lt;P&gt;Do selective updating of mt_corr, then selective updating of mt_2.&amp;nbsp; This program is untested, but it should fill in the yellow cells in your data:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
data matable3;
  set matable2;
  by numero code2;
  retain mt_corr;
  if first.code2 then mt_corr=.;
  if mt_2^=. then mt_corr=mt_2;
  else mt_2=mt_corr;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 10 Mar 2024 16:47:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Retain-the-last-data-until-the-non-empty-row/m-p/919683#M362253</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2024-03-10T16:47:44Z</dc:date>
    </item>
    <item>
      <title>Re: Retain the last data until the non empty row</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Retain-the-last-data-until-the-non-empty-row/m-p/919684#M362254</link>
      <description>&lt;P&gt;&lt;STRONG&gt;Just use the UPDATE statement.&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;If you want to carry forward all of the variables then use:&lt;/STRONG&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;STRONG&gt;&lt;CODE class=" language-sas"&gt;data matable3;
  update matable2(obs=2) matable2;
  by numero code2;
  output;
run;&lt;/CODE&gt;&lt;/STRONG&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;STRONG&gt;If there are some that you don't want the missing values replaced with the previous value then re-read those variables.&lt;/STRONG&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;STRONG&gt;&lt;CODE class=" language-sas"&gt;data matable3;
  update matable2(obs=2) matable2;
  by numero code2;
  set matable2(keep=other);
  output;
run;&lt;/CODE&gt;&lt;/STRONG&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;STRONG&gt;PS&lt;/STRONG&gt; No need (or desire) to post on XLSX file to share example data.&amp;nbsp; A simple data step is easier to create and very much easier for others to use to create your example data.&lt;/P&gt;
&lt;PRE&gt;data have;
  input numero $ code2 $ date :yymmdd. mt_2 expect;
  format date yymmdd10.;
cards;
CC1 X 2019-07-18 204167.73653 204167.73653
CC1 X 2019-08-06 . 204167.73653
CC1 X 2019-08-06 . 204167.73653
CC1 X 2019-09-30 313986.57001 313986.57001
CC1 X 2019-09-30 313986.57001 313986.57001
CC1 X 2019-09-30 313986.57001 313986.57001
CC1 X 2019-09-30 313986.57001 313986.57001
CC1 X 2019-09-30 313986.57001 313986.57001
CC1 X 2019-09-30 313986.57001 313986.57001
CC1 X 2019-12-10 313986.57001 313986.57001
CC1 X 2019-12-10 313986.57001 313986.57001
CC1 X 2019-12-31 339560.10139 339560.10139
CC1 X 2019-12-31 . 339560.10139
CC1 X 2019-12-31 . 339560.10139
PPK LT 2019-07-18 5000.7365312 5000.7365312
PPK LT 2019-08-06 . 5000.7365312
PPK LT 2019-08-06 . 5000.7365312
PPK LT 2019-09-30 . 5000.7365312
PPK LT 2019-12-31 . 5000.7365312
PPK LT 2019-12-31 7000.1013906 7000.1013906
PPK LT 2019-12-31 7050.1013906 7050.1013906
;&lt;/PRE&gt;</description>
      <pubDate>Sun, 10 Mar 2024 17:09:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Retain-the-last-data-until-the-non-empty-row/m-p/919684#M362254</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2024-03-10T17:09:15Z</dc:date>
    </item>
  </channel>
</rss>

