<?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 - IF ELSE in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/PROC-SQL-IF-ELSE/m-p/331338#M74445</link>
    <description>&lt;P&gt;Macro&amp;nbsp;language&amp;nbsp;does&amp;nbsp;not have access to dataset variable values :%IF TRIM(B.NEW_PLAT) would require the MACRO processor to know the value of the variable New_plat in the referenced source B.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;SQL does not use IF/then syntax at all.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Can you describe what you are attempting with this code? Provide some example data and the desired output with some rules.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Part of what you may be wanting is&lt;/P&gt;
&lt;P&gt;Where B.CLAIM_ID_NEW = '' AND TRIM(B.NEW_PLAT) in ('ABC'&amp;nbsp;,'XYZ')&amp;nbsp; Which on a where clause restricts the output to cases where this is true and the IN operator returns a true/false response based on the valur of the variable on the left of IN.&lt;/P&gt;
&lt;P&gt;TRIM(A.&amp;amp;PROV_BIL_TIN) || A.SITE introduces a macro variable and the || concatenation operator is a likely cause of embedded spaces&lt;/P&gt;</description>
    <pubDate>Thu, 09 Feb 2017 21:32:47 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2017-02-09T21:32:47Z</dc:date>
    <item>
      <title>PROC SQL - IF ELSE</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROC-SQL-IF-ELSE/m-p/331330#M74443</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hi SAS USers,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Need some help on SQL - IF&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My code is giving the sytax error. &amp;nbsp;DB_A_Table is a oracle table &amp;nbsp; &amp;nbsp;PL_TAB is excel datset.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Erroring at&amp;nbsp;&lt;SPAN&gt;%IF TRIM(B.NEW_PLAT) = 'ABC' OR TRIM(B.NEW_PLAT) ='&lt;/SPAN&gt;&lt;SPAN&gt;XYZ&lt;/SPAN&gt;&lt;SPAN&gt;' &amp;nbsp;- &amp;nbsp;says syntax is wrong.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;CAn this be written in different way if this coding method is wrong?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;PROC SQL;&lt;BR /&gt;SELECT count(distinct B.&lt;SPAN&gt;NEW_PROV_BIL_TIN)&lt;/SPAN&gt;&amp;nbsp;INTO :PNQ_obs&lt;BR /&gt;FROM DB.A_Table&amp;nbsp;A ,PL_TAB B&lt;BR /&gt;WHERE B.CLAIM_ID_NEW = '' AND (%IF TRIM(B.NEW_PLAT) = 'ABC' OR TRIM(B.NEW_PLAT) ='XYZ') %THEN %DO;&lt;BR /&gt;( TRIM(A.&amp;amp;PROV_BIL_TIN) || A.SITE = TRIM(B.NEW_PROV_BIL_TIN) ) %END;&lt;BR /&gt;%ELSE %DO; (A.&amp;amp;PROV_BIL_TIN = TRIM(B.NEW_PROV_BIL_TIN) %END;&lt;BR /&gt;AND A.DATE = &amp;amp;ARUN_DT&lt;BR /&gt;AND A.ID = &amp;amp;ID&lt;BR /&gt;;&lt;BR /&gt;QUIT;&lt;BR /&gt;%put &amp;amp;=PNQ_obs;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 09 Feb 2017 21:06:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROC-SQL-IF-ELSE/m-p/331330#M74443</guid>
      <dc:creator>SASAna</dc:creator>
      <dc:date>2017-02-09T21:06:41Z</dc:date>
    </item>
    <item>
      <title>Re: PROC SQL - IF ELSE</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROC-SQL-IF-ELSE/m-p/331338#M74445</link>
      <description>&lt;P&gt;Macro&amp;nbsp;language&amp;nbsp;does&amp;nbsp;not have access to dataset variable values :%IF TRIM(B.NEW_PLAT) would require the MACRO processor to know the value of the variable New_plat in the referenced source B.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;SQL does not use IF/then syntax at all.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Can you describe what you are attempting with this code? Provide some example data and the desired output with some rules.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Part of what you may be wanting is&lt;/P&gt;
&lt;P&gt;Where B.CLAIM_ID_NEW = '' AND TRIM(B.NEW_PLAT) in ('ABC'&amp;nbsp;,'XYZ')&amp;nbsp; Which on a where clause restricts the output to cases where this is true and the IN operator returns a true/false response based on the valur of the variable on the left of IN.&lt;/P&gt;
&lt;P&gt;TRIM(A.&amp;amp;PROV_BIL_TIN) || A.SITE introduces a macro variable and the || concatenation operator is a likely cause of embedded spaces&lt;/P&gt;</description>
      <pubDate>Thu, 09 Feb 2017 21:32:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROC-SQL-IF-ELSE/m-p/331338#M74445</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2017-02-09T21:32:47Z</dc:date>
    </item>
    <item>
      <title>Re: PROC SQL - IF ELSE</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROC-SQL-IF-ELSE/m-p/331340#M74446</link>
      <description>&lt;P&gt;Will never work. Macro statements are executed before the SQL code is even fed to the interpreter.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For conditions in SQL, use case/when/else/end to create variables, and use those results in a having clause.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Read the documentation for proc sql.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And use the "little running man" button to post code. Keeps formatting and prevents unwanted smileys.&lt;/P&gt;</description>
      <pubDate>Thu, 09 Feb 2017 21:34:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROC-SQL-IF-ELSE/m-p/331340#M74446</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2017-02-09T21:34:09Z</dc:date>
    </item>
  </channel>
</rss>

