<?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 if statement in many to many merge in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/if-statement-in-many-to-many-merge/m-p/304928#M64986</link>
    <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In this program, I wonder why IF statement does not work. I have inherited programs like this ie. using IF statement after OUTPUT statement.&lt;/P&gt;&lt;PRE&gt;data a;
input a;
cards;
1
2
3
;
run;

data b;
input b;
cards;
4
5
6
;
run;

data want;
  set a;
  do i = 1 to nobs;
     set b point=i nobs = nobs;
       output;
  end;
  if b &amp;gt; 5;
run;&lt;/PRE&gt;</description>
    <pubDate>Sun, 16 Oct 2016 16:00:15 GMT</pubDate>
    <dc:creator>SAS_inquisitive</dc:creator>
    <dc:date>2016-10-16T16:00:15Z</dc:date>
    <item>
      <title>if statement in many to many merge</title>
      <link>https://communities.sas.com/t5/SAS-Programming/if-statement-in-many-to-many-merge/m-p/304928#M64986</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In this program, I wonder why IF statement does not work. I have inherited programs like this ie. using IF statement after OUTPUT statement.&lt;/P&gt;&lt;PRE&gt;data a;
input a;
cards;
1
2
3
;
run;

data b;
input b;
cards;
4
5
6
;
run;

data want;
  set a;
  do i = 1 to nobs;
     set b point=i nobs = nobs;
       output;
  end;
  if b &amp;gt; 5;
run;&lt;/PRE&gt;</description>
      <pubDate>Sun, 16 Oct 2016 16:00:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/if-statement-in-many-to-many-merge/m-p/304928#M64986</guid>
      <dc:creator>SAS_inquisitive</dc:creator>
      <dc:date>2016-10-16T16:00:15Z</dc:date>
    </item>
    <item>
      <title>Re: if statement in many to many merge</title>
      <link>https://communities.sas.com/t5/SAS-Programming/if-statement-in-many-to-many-merge/m-p/304932#M64988</link>
      <description>&lt;P&gt;This subsetting if is completely useless. The explicit output statement in the loop deactivates the implicit output that usually happens at the conclusion of a data step iteration.&lt;/P&gt;</description>
      <pubDate>Sun, 16 Oct 2016 18:43:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/if-statement-in-many-to-many-merge/m-p/304932#M64988</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2016-10-16T18:43:51Z</dc:date>
    </item>
    <item>
      <title>Re: if statement in many to many merge</title>
      <link>https://communities.sas.com/t5/SAS-Programming/if-statement-in-many-to-many-merge/m-p/304940#M64991</link>
      <description>&lt;P&gt;Did you mean to do:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;data want;
  set a;
  do i = 1 to nobs;
     set b point=i nobs = nobs;
       &lt;STRONG&gt;if b &amp;gt; 5 then&lt;/STRONG&gt; output;
  end;
  
run;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 16 Oct 2016 21:22:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/if-statement-in-many-to-many-merge/m-p/304940#M64991</guid>
      <dc:creator>Shmuel</dc:creator>
      <dc:date>2016-10-16T21:22:23Z</dc:date>
    </item>
    <item>
      <title>Re: if statement in many to many merge</title>
      <link>https://communities.sas.com/t5/SAS-Programming/if-statement-in-many-to-many-merge/m-p/304941#M64992</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/88384"&gt;@Shmuel﻿&lt;/a&gt;&amp;nbsp;This is how it should be done. As I mentioned earlier, I have some programs that have used subsetting IF after explicit OUTPUT statement that confused me.&lt;/P&gt;</description>
      <pubDate>Sun, 16 Oct 2016 21:36:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/if-statement-in-many-to-many-merge/m-p/304941#M64992</guid>
      <dc:creator>SAS_inquisitive</dc:creator>
      <dc:date>2016-10-16T21:36:34Z</dc:date>
    </item>
    <item>
      <title>Re: if statement in many to many merge</title>
      <link>https://communities.sas.com/t5/SAS-Programming/if-statement-in-many-to-many-merge/m-p/304944#M64995</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/64404"&gt;@SAS_inquisitive﻿&lt;/a&gt;&amp;nbsp;In this particular case it's useless. We can't say that about all cases.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 16 Oct 2016 22:04:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/if-statement-in-many-to-many-merge/m-p/304944#M64995</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-10-16T22:04:33Z</dc:date>
    </item>
    <item>
      <title>Re: if statement in many to many merge</title>
      <link>https://communities.sas.com/t5/SAS-Programming/if-statement-in-many-to-many-merge/m-p/304945#M64996</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13879"&gt;@Reeza﻿&lt;/a&gt;&amp;nbsp;I wonder if you have any example.&lt;/P&gt;</description>
      <pubDate>Sun, 16 Oct 2016 22:09:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/if-statement-in-many-to-many-merge/m-p/304945#M64996</guid>
      <dc:creator>SAS_inquisitive</dc:creator>
      <dc:date>2016-10-16T22:09:38Z</dc:date>
    </item>
    <item>
      <title>Re: if statement in many to many merge</title>
      <link>https://communities.sas.com/t5/SAS-Programming/if-statement-in-many-to-many-merge/m-p/304955#M64998</link>
      <description>&lt;P&gt;Your example is a subsetting IF, any IF that operated on a variable that was retained from obs to obs would be affected.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This is a useless example, but I know for a fact that I've used this to increment a value after the OUTPUT statement on purpose to retain a value across rows. There are multiple ways to do this and I can't come up with a good example but it has it's uses. Note that in the example below the effective rate in the log is different than the effective rate on the data set.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
do i=1 to 100;
rate=0.05; deposit=100;
output;
end;
run;

data want;
set have;
retain effective_rate 0.03 x 0;

x=deposit+x*(1+effective_rate);

output;

effective_rate =(rate**_n_);

put effective_rate;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 16 Oct 2016 23:01:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/if-statement-in-many-to-many-merge/m-p/304955#M64998</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-10-16T23:01:02Z</dc:date>
    </item>
    <item>
      <title>Re: if statement in many to many merge</title>
      <link>https://communities.sas.com/t5/SAS-Programming/if-statement-in-many-to-many-merge/m-p/304960#M65001</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/64404"&gt;@SAS_inquisitive﻿&lt;/a&gt;&amp;nbsp;- using statement like &amp;nbsp;"&lt;STRONG&gt;IF&amp;nbsp;&amp;lt;condition&amp;gt; ;&lt;/STRONG&gt;&amp;nbsp;" intends to &lt;U&gt;filter&lt;/U&gt; implicit &lt;STRONG&gt;output&lt;/STRONG&gt;;&lt;/P&gt;&lt;P&gt;In your code, the explicit&amp;nbsp;&lt;STRONG&gt;output&lt;/STRONG&gt; was already done and the &lt;STRONG&gt;IF&lt;/STRONG&gt; statement has no effect.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You wrote "...&lt;SPAN&gt;why &lt;STRONG&gt;IF&lt;/STRONG&gt; statement &lt;U&gt;does not work&lt;/U&gt;.&lt;/SPAN&gt;" - what was your target when adding this &lt;STRONG&gt;IF&lt;/STRONG&gt;&amp;nbsp;statement ?&lt;/P&gt;&lt;P&gt;If your target was to filter output then your code should be:&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;STRONG&gt; IF B &amp;gt; 5 then output;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In&amp;nbsp;&lt;STRONG&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13879"&gt;@Reeza﻿&lt;/a&gt;&lt;/STRONG&gt;'s example, the statment following &lt;STRONG&gt;OUTPUT&lt;/STRONG&gt; is to deal with a &lt;STRONG&gt;retained&lt;/STRONG&gt; variable, that may affect &lt;U&gt;next&lt;/U&gt; itteration.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 17 Oct 2016 01:10:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/if-statement-in-many-to-many-merge/m-p/304960#M65001</guid>
      <dc:creator>Shmuel</dc:creator>
      <dc:date>2016-10-17T01:10:13Z</dc:date>
    </item>
  </channel>
</rss>

