<?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: repeat code based on previous table in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/repeat-code-based-on-previous-table/m-p/497638#M131963</link>
    <description>thank you for your answer! It works for my data.</description>
    <pubDate>Fri, 21 Sep 2018 00:43:25 GMT</pubDate>
    <dc:creator>jojozheng</dc:creator>
    <dc:date>2018-09-21T00:43:25Z</dc:date>
    <item>
      <title>repeat code based on previous table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/repeat-code-based-on-previous-table/m-p/497234#M131719</link>
      <description>&lt;P&gt;I'm very new to Macro. I have 5 variables A,B,C,D,E. also I have a code need to repeat, this code used for filling up previous missing value.&lt;/P&gt;&lt;PRE class=" language-sas"&gt;&lt;CODE class="  language-sas"&gt;&lt;SPAN class="token procnames"&gt;data&lt;/SPAN&gt; want&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
 do until&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;&lt;SPAN class="token operator"&gt;not&lt;/SPAN&gt; &lt;SPAN class="token function"&gt;missing&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;status&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt; or last&lt;SPAN class="token punctuation"&gt;.&lt;/SPAN&gt;&lt;SPAN class="token keyword"&gt;id&lt;/SPAN&gt; &lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
  &lt;SPAN class="token keyword"&gt;set&lt;/SPAN&gt; have&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
  &lt;SPAN class="token statement"&gt;by&lt;/SPAN&gt; &lt;SPAN class="token keyword"&gt;id&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;  
 end&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
 temp&lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt;status&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
 do until&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;&lt;SPAN class="token operator"&gt;not&lt;/SPAN&gt; &lt;SPAN class="token function"&gt;missing&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;status&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt; or last&lt;SPAN class="token punctuation"&gt;.&lt;/SPAN&gt;&lt;SPAN class="token keyword"&gt;id&lt;/SPAN&gt; &lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
  &lt;SPAN class="token keyword"&gt;set&lt;/SPAN&gt; have&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
  &lt;SPAN class="token statement"&gt;by&lt;/SPAN&gt; &lt;SPAN class="token keyword"&gt;id&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
  _status&lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt;temp&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;output&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
 end&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
 &lt;SPAN class="token keyword"&gt;drop&lt;/SPAN&gt; temp status&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
&lt;SPAN class="token procnames"&gt;run&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;I need input variable A into this code, then generate table A, then use tableA as base table, then input variableB into tableA, and so on, until I input last variable E. So final table E will come out, which contains all 5 variables with filling values.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;My logic to get what I want:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;data tableA;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;set old;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;(fill up variableA);&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data tableB;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;set tableA;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;(same fill up code to fill up tableB);&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;.....&lt;/P&gt;&lt;P&gt;data tableE;----------&lt;STRONG&gt;FINAL table filling up all missing values for 5 variables.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;set tableD;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;(same fill up code tp input variableE);&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;sample data have:&lt;/P&gt;&lt;P&gt;id&amp;nbsp; &amp;nbsp; varA&amp;nbsp; &amp;nbsp; &amp;nbsp;B&amp;nbsp; &amp;nbsp; &amp;nbsp; C&amp;nbsp; &amp;nbsp; &amp;nbsp; D&amp;nbsp; &amp;nbsp; &amp;nbsp; E&lt;/P&gt;&lt;P&gt;1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;.&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;.&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; .&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;.&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; .&lt;/P&gt;&lt;P&gt;1&amp;nbsp; &amp;nbsp; &amp;nbsp; n&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; m&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;l&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;p&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;k&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;want:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;id&amp;nbsp; &amp;nbsp; varA&amp;nbsp; &amp;nbsp; &amp;nbsp;B&amp;nbsp; &amp;nbsp; &amp;nbsp; C&amp;nbsp; &amp;nbsp; &amp;nbsp; D&amp;nbsp; &amp;nbsp; &amp;nbsp; E&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;1&amp;nbsp; &amp;nbsp; &amp;nbsp; n&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; m&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;l&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;p&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;k&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;1&amp;nbsp; &amp;nbsp; &amp;nbsp; n&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; m&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;l&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;p&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;k&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I know how to fill up one by one. I'm thinking if I can use macro to get this final table? or other ways to do that? Thank you for your help! Appreciate!&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 20 Sep 2018 04:20:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/repeat-code-based-on-previous-table/m-p/497234#M131719</guid>
      <dc:creator>jojozheng</dc:creator>
      <dc:date>2018-09-20T04:20:43Z</dc:date>
    </item>
    <item>
      <title>Re: repeat code based on previous table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/repeat-code-based-on-previous-table/m-p/497243#M131725</link>
      <description>Please show an example of your starting data and what you expect as the end data. Preferably one that aligns so that if we ran the code on the starting data, we could get exactly the end data.</description>
      <pubDate>Thu, 20 Sep 2018 04:03:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/repeat-code-based-on-previous-table/m-p/497243#M131725</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-09-20T04:03:32Z</dc:date>
    </item>
    <item>
      <title>Re: repeat code based on previous table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/repeat-code-based-on-previous-table/m-p/497248#M131729</link>
      <description>thank you for suggestion. just edited the post.</description>
      <pubDate>Thu, 20 Sep 2018 04:21:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/repeat-code-based-on-previous-table/m-p/497248#M131729</guid>
      <dc:creator>jojozheng</dc:creator>
      <dc:date>2018-09-20T04:21:19Z</dc:date>
    </item>
    <item>
      <title>Re: repeat code based on previous table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/repeat-code-based-on-previous-table/m-p/497258#M131741</link>
      <description>&lt;P&gt;There are numerous ways of doing it, for example:&lt;/P&gt;
&lt;PRE&gt;data have;
  infile datalines dlm="," dsd;
  input id vara $ varb $ varc $ vard $ vare $;
datalines;
1,,,,,
1,n,m,l,p,k
;
run;

data want;
  update have have (where=(vara ne ""));
  by id;
run;&lt;/PRE&gt;
&lt;P&gt;Or:&lt;/P&gt;
&lt;PRE&gt;data want;
  set have (where=(vara ne ""))
        have (where=(vara ne "");
run;&lt;/PRE&gt;
&lt;P&gt;But i dont think its that straight forward, I can only go on your test data however.&amp;nbsp; Please post test data in the form of a datastep as I have done above in future.&lt;/P&gt;</description>
      <pubDate>Thu, 20 Sep 2018 07:23:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/repeat-code-based-on-previous-table/m-p/497258#M131741</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2018-09-20T07:23:51Z</dc:date>
    </item>
    <item>
      <title>Re: repeat code based on previous table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/repeat-code-based-on-previous-table/m-p/497340#M131788</link>
      <description>&lt;P&gt;You can do it all in one easy step, somewhat similar to the&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/45151"&gt;@RW9&lt;/a&gt;&amp;nbsp;suggestion:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data want;&lt;/P&gt;
&lt;P&gt;update have (obs=0) have;&lt;/P&gt;
&lt;P&gt;by id;&lt;/P&gt;
&lt;P&gt;output;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Note that this will affect all variables, not just the five of interest.&lt;/P&gt;</description>
      <pubDate>Thu, 20 Sep 2018 12:50:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/repeat-code-based-on-previous-table/m-p/497340#M131788</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2018-09-20T12:50:49Z</dc:date>
    </item>
    <item>
      <title>Re: repeat code based on previous table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/repeat-code-based-on-previous-table/m-p/497638#M131963</link>
      <description>thank you for your answer! It works for my data.</description>
      <pubDate>Fri, 21 Sep 2018 00:43:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/repeat-code-based-on-previous-table/m-p/497638#M131963</guid>
      <dc:creator>jojozheng</dc:creator>
      <dc:date>2018-09-21T00:43:25Z</dc:date>
    </item>
    <item>
      <title>Re: repeat code based on previous table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/repeat-code-based-on-previous-table/m-p/497640#M131965</link>
      <description>thank you for your help! the code looks more simple !</description>
      <pubDate>Fri, 21 Sep 2018 00:44:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/repeat-code-based-on-previous-table/m-p/497640#M131965</guid>
      <dc:creator>jojozheng</dc:creator>
      <dc:date>2018-09-21T00:44:53Z</dc:date>
    </item>
  </channel>
</rss>

