<?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 Or statement for sql in a macro in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Or-statement-for-sql-in-a-macro/m-p/369750#M65060</link>
    <description>&lt;PRE&gt; %if &amp;amp;table=3 or &amp;amp;table=3a or &amp;amp;table=3b or &amp;amp;table=3c %then %do; 
    proc sql;
	create table want1 as
    select a.county, c.count, c.imm, c.missing, c.med, c.bel, c.oth, c.over
     from counties as a
	left join have as c
		on a.county=c.county;
   quit;
 %end;&lt;/PRE&gt;
&lt;P&gt;I inherited a program am trying to modify it.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;table 'have' has a list of 50 counties along with additional variables.&lt;/P&gt;
&lt;P&gt;table 'counties' has a list of all desired 60 counties, one per rown&lt;/P&gt;
&lt;P&gt;table 'want' I need all 60 counties listed, one per row,&amp;nbsp;in the table 'counties' joined by county name to the table 'have' with the following column names:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;county&amp;nbsp; count imm missing med bel oth over&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;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;When I run the sql code without using the or statement (i,e, repeat &amp;nbsp;, the sql statement works (I get 60 rows).&amp;nbsp;If I run the macro just with one table name, I still am getting only 50 rows as output.&amp;nbsp; How do I troubleshoot? Thanks.&lt;/P&gt;</description>
    <pubDate>Fri, 23 Jun 2017 01:59:13 GMT</pubDate>
    <dc:creator>jcis7</dc:creator>
    <dc:date>2017-06-23T01:59:13Z</dc:date>
    <item>
      <title>Or statement for sql in a macro</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Or-statement-for-sql-in-a-macro/m-p/369750#M65060</link>
      <description>&lt;PRE&gt; %if &amp;amp;table=3 or &amp;amp;table=3a or &amp;amp;table=3b or &amp;amp;table=3c %then %do; 
    proc sql;
	create table want1 as
    select a.county, c.count, c.imm, c.missing, c.med, c.bel, c.oth, c.over
     from counties as a
	left join have as c
		on a.county=c.county;
   quit;
 %end;&lt;/PRE&gt;
&lt;P&gt;I inherited a program am trying to modify it.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;table 'have' has a list of 50 counties along with additional variables.&lt;/P&gt;
&lt;P&gt;table 'counties' has a list of all desired 60 counties, one per rown&lt;/P&gt;
&lt;P&gt;table 'want' I need all 60 counties listed, one per row,&amp;nbsp;in the table 'counties' joined by county name to the table 'have' with the following column names:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;county&amp;nbsp; count imm missing med bel oth over&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;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;When I run the sql code without using the or statement (i,e, repeat &amp;nbsp;, the sql statement works (I get 60 rows).&amp;nbsp;If I run the macro just with one table name, I still am getting only 50 rows as output.&amp;nbsp; How do I troubleshoot? Thanks.&lt;/P&gt;</description>
      <pubDate>Fri, 23 Jun 2017 01:59:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Or-statement-for-sql-in-a-macro/m-p/369750#M65060</guid>
      <dc:creator>jcis7</dc:creator>
      <dc:date>2017-06-23T01:59:13Z</dc:date>
    </item>
    <item>
      <title>Re: Or statement for sql in a macro</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Or-statement-for-sql-in-a-macro/m-p/369754#M65061</link>
      <description>&lt;P&gt;From what you've shown, your code will only ever run once, there's nothing dynamic in it, so the results will be the same regardless of the table name(s) as long as they meet one of the table names in the OR list.&lt;/P&gt;
&lt;P&gt;Are you expecting it to run multiple times?&lt;/P&gt;</description>
      <pubDate>Fri, 23 Jun 2017 02:21:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Or-statement-for-sql-in-a-macro/m-p/369754#M65061</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-06-23T02:21:29Z</dc:date>
    </item>
    <item>
      <title>Re: Or statement for sql in a macro</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Or-statement-for-sql-in-a-macro/m-p/369785#M65062</link>
      <description>&lt;P&gt;If you get different outcomes from this step, then it is not the %if condition, but changes in the input datasets. There is nothing dynamic in the SQL, so it will always work the same, but &lt;U&gt;the outcome will depend on the input datasets&lt;/U&gt;.&lt;/P&gt;</description>
      <pubDate>Fri, 23 Jun 2017 06:50:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Or-statement-for-sql-in-a-macro/m-p/369785#M65062</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2017-06-23T06:50:45Z</dc:date>
    </item>
    <item>
      <title>Re: Or statement for sql in a macro</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Or-statement-for-sql-in-a-macro/m-p/369943#M65072</link>
      <description>&lt;P&gt;Thanks everyone. I figured out what I did wrong.&lt;/P&gt;</description>
      <pubDate>Fri, 23 Jun 2017 15:28:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Or-statement-for-sql-in-a-macro/m-p/369943#M65072</guid>
      <dc:creator>jcis7</dc:creator>
      <dc:date>2017-06-23T15:28:07Z</dc:date>
    </item>
    <item>
      <title>Re: Or statement for sql in a macro</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Or-statement-for-sql-in-a-macro/m-p/370018#M65074</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/40498"&gt;@jcis7&lt;/a&gt;&amp;nbsp;please mark one of the solutions as correct.&lt;/P&gt;</description>
      <pubDate>Fri, 23 Jun 2017 17:11:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Or-statement-for-sql-in-a-macro/m-p/370018#M65074</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-06-23T17:11:41Z</dc:date>
    </item>
  </channel>
</rss>

