<?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: Proc Sql in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Proc-Sql-Condition-inclusion-of-variable-from-different-tables/m-p/606263#M176037</link>
    <description>&lt;P&gt;When WHAT?&amp;nbsp; How are you joining table A and table B so that both available to reference the CASE?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;select 
  case when ( ????) then A.A else B.B end as A_or_B
   from A , B
;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Or are you taling about generating code based on some external condition.&amp;nbsp; So perhaps the value of some macro variable?&amp;nbsp; If so then use macro logic to conditionally generate the statement you want to create.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%if &amp;amp;XX= OPTION1 %then %do;
select A from A;
%end;
%else %do;
select B from B;
%end;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Thu, 21 Nov 2019 19:32:50 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2019-11-21T19:32:50Z</dc:date>
    <item>
      <title>Proc Sql - Condition inclusion of variable from different tables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-Sql-Condition-inclusion-of-variable-from-different-tables/m-p/606261#M176035</link>
      <description>&lt;P&gt;How to do -- Case when then select ( column A from table A) else select column b from table b.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 21 Nov 2019 20:28:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-Sql-Condition-inclusion-of-variable-from-different-tables/m-p/606261#M176035</guid>
      <dc:creator>Sara1</dc:creator>
      <dc:date>2019-11-21T20:28:03Z</dc:date>
    </item>
    <item>
      <title>Re: Proc Sql</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-Sql-Condition-inclusion-of-variable-from-different-tables/m-p/606263#M176037</link>
      <description>&lt;P&gt;When WHAT?&amp;nbsp; How are you joining table A and table B so that both available to reference the CASE?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;select 
  case when ( ????) then A.A else B.B end as A_or_B
   from A , B
;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Or are you taling about generating code based on some external condition.&amp;nbsp; So perhaps the value of some macro variable?&amp;nbsp; If so then use macro logic to conditionally generate the statement you want to create.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%if &amp;amp;XX= OPTION1 %then %do;
select A from A;
%end;
%else %do;
select B from B;
%end;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 21 Nov 2019 19:32:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-Sql-Condition-inclusion-of-variable-from-different-tables/m-p/606263#M176037</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-11-21T19:32:50Z</dc:date>
    </item>
    <item>
      <title>Re: Proc Sql</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-Sql-Condition-inclusion-of-variable-from-different-tables/m-p/606267#M176038</link>
      <description>&lt;P&gt;Is this what you are trying to do?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
    select case when &amp;lt;put logic here&amp;gt; then a.column_A else b.column_B end as new_column
    from table_A as a
    join table_B as b on &amp;lt;put join here&amp;gt;;
quit;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 21 Nov 2019 19:34:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-Sql-Condition-inclusion-of-variable-from-different-tables/m-p/606267#M176038</guid>
      <dc:creator>supp</dc:creator>
      <dc:date>2019-11-21T19:34:49Z</dc:date>
    </item>
    <item>
      <title>Re: Proc Sql</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-Sql-Condition-inclusion-of-variable-from-different-tables/m-p/606269#M176039</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;SELECT CASE WHEN A.ID = X THEN A.COLUMN
            ELSE B.COLUMN
        END AS NAME
  FROM TableA A
  JOIN TableB B on A.ID = B.ID&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 21 Nov 2019 19:37:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-Sql-Condition-inclusion-of-variable-from-different-tables/m-p/606269#M176039</guid>
      <dc:creator>Krueger</dc:creator>
      <dc:date>2019-11-21T19:37:04Z</dc:date>
    </item>
    <item>
      <title>Re: Proc Sql - Condition inclusion of variable from different tables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-Sql-Condition-inclusion-of-variable-from-different-tables/m-p/606285#M176045</link>
      <description>It depends on the rest of the query - COALESECE() may be an option for example. Is table B already in the query somewhere?</description>
      <pubDate>Thu, 21 Nov 2019 20:28:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-Sql-Condition-inclusion-of-variable-from-different-tables/m-p/606285#M176045</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2019-11-21T20:28:42Z</dc:date>
    </item>
  </channel>
</rss>

