<?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 carrying forward values in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/carrying-forward-values/m-p/557667#M10006</link>
    <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hi everyone,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a long dataset and some missingness in my data. For places where there are some gaps in data I was wanting to carry forward the most recent value a maximum of TWO times. I have this code that carries forward the value of smokestat until the next non-missing value of smokestat, but I don't want it to carry it forward that far. I was having some issues adapting this code to only carry it forward a maximum of two visits. Any help appreciated!&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data Aim2.Final; set Aim2.Final;
	 n=_n_;
	 if missing(smokestat) then do;
	   do until (not missing(smokestat));
	     n=n-1;
	     set Aim2.Final(keep=smokestat) point=n;  
	   end;
	 end;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Hi everyone,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 10 May 2019 01:47:38 GMT</pubDate>
    <dc:creator>bgosiker</dc:creator>
    <dc:date>2019-05-10T01:47:38Z</dc:date>
    <item>
      <title>carrying forward values</title>
      <link>https://communities.sas.com/t5/New-SAS-User/carrying-forward-values/m-p/557667#M10006</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hi everyone,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a long dataset and some missingness in my data. For places where there are some gaps in data I was wanting to carry forward the most recent value a maximum of TWO times. I have this code that carries forward the value of smokestat until the next non-missing value of smokestat, but I don't want it to carry it forward that far. I was having some issues adapting this code to only carry it forward a maximum of two visits. Any help appreciated!&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data Aim2.Final; set Aim2.Final;
	 n=_n_;
	 if missing(smokestat) then do;
	   do until (not missing(smokestat));
	     n=n-1;
	     set Aim2.Final(keep=smokestat) point=n;  
	   end;
	 end;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Hi everyone,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 10 May 2019 01:47:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/carrying-forward-values/m-p/557667#M10006</guid>
      <dc:creator>bgosiker</dc:creator>
      <dc:date>2019-05-10T01:47:38Z</dc:date>
    </item>
    <item>
      <title>Re: carrying forward values</title>
      <link>https://communities.sas.com/t5/New-SAS-User/carrying-forward-values/m-p/557673#M10007</link>
      <description>&lt;P&gt;A reasonable approach:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
   set have;
   retain n replacement;
   if smokestat &amp;gt; . then do;
      replacement = smokestat;
      n = 0;
   end;
   else do;
      n + 1;
      smokestat = replacement;
      if n = 2 then call missing(replacement);
   end;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 10 May 2019 02:30:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/carrying-forward-values/m-p/557673#M10007</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2019-05-10T02:30:54Z</dc:date>
    </item>
  </channel>
</rss>

