<?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: Run Proc Sql base on conditions in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Run-Proc-Sql-base-on-conditions/m-p/484681#M125842</link>
    <description>&lt;P&gt;Format your code and you will note where additional things are not needed.&amp;nbsp; The cause of your issue is that the macro call is not finished with a ; - always ensure you finish things correctly, end of statemetns with semi colon, end of macro variables with a dot etc.&lt;/P&gt;
&lt;PRE&gt;data test;
input rptinput $;
cards;
Report1
;
run;

proc sql noprint;
  select distinct rptinput
  into :REPORT separated by ''
  from test;
quit;

%macro condtest;
  proc sql;
  %if "&amp;amp;report." eq "Report1" %then %do;
    select * from Sashelp.shoes;
  %end;
  %else %if "&amp;amp;report." eq "Report2" %then %do;
    select * from Sashelp.cars;
  %end;&lt;BR /&gt;  quit;
%mend condtest;

%condtest;
&lt;/PRE&gt;</description>
    <pubDate>Tue, 07 Aug 2018 10:29:03 GMT</pubDate>
    <dc:creator>RW9</dc:creator>
    <dc:date>2018-08-07T10:29:03Z</dc:date>
    <item>
      <title>Run Proc Sql base on conditions</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Run-Proc-Sql-base-on-conditions/m-p/484676#M125840</link>
      <description>&lt;P&gt;I tried to run the below codes but it won't execute, anyone can help? Many thanks.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;data test;&lt;BR /&gt;input rptinput $;&lt;BR /&gt;cards;&lt;BR /&gt;Report1&lt;BR /&gt;;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc sql noprint;&lt;BR /&gt;select distinct rptinput&lt;BR /&gt;into :REPORT separated by ''&lt;BR /&gt;from test;&lt;BR /&gt;quit;&lt;BR /&gt;%put &amp;amp;report;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%macro condtest;&lt;BR /&gt;%if &amp;amp;report eq "Report1" %then %do;&lt;BR /&gt;proc sql;&lt;BR /&gt;select * from Sashelp.shoes;&lt;BR /&gt;%end;&lt;BR /&gt;%else %if &amp;amp;report eq "Report2" %then %do;&lt;BR /&gt;proc sql;&lt;BR /&gt;select * from Sashelp.cars;&lt;BR /&gt;;&lt;BR /&gt;%end;&lt;BR /&gt;%mend condtest;&lt;BR /&gt;quit;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%condtest&lt;BR /&gt;quit;&lt;/P&gt;</description>
      <pubDate>Tue, 07 Aug 2018 10:11:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Run-Proc-Sql-base-on-conditions/m-p/484676#M125840</guid>
      <dc:creator>scb</dc:creator>
      <dc:date>2018-08-07T10:11:21Z</dc:date>
    </item>
    <item>
      <title>Re: Run Proc Sql base on conditions</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Run-Proc-Sql-base-on-conditions/m-p/484681#M125842</link>
      <description>&lt;P&gt;Format your code and you will note where additional things are not needed.&amp;nbsp; The cause of your issue is that the macro call is not finished with a ; - always ensure you finish things correctly, end of statemetns with semi colon, end of macro variables with a dot etc.&lt;/P&gt;
&lt;PRE&gt;data test;
input rptinput $;
cards;
Report1
;
run;

proc sql noprint;
  select distinct rptinput
  into :REPORT separated by ''
  from test;
quit;

%macro condtest;
  proc sql;
  %if "&amp;amp;report." eq "Report1" %then %do;
    select * from Sashelp.shoes;
  %end;
  %else %if "&amp;amp;report." eq "Report2" %then %do;
    select * from Sashelp.cars;
  %end;&lt;BR /&gt;  quit;
%mend condtest;

%condtest;
&lt;/PRE&gt;</description>
      <pubDate>Tue, 07 Aug 2018 10:29:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Run-Proc-Sql-base-on-conditions/m-p/484681#M125842</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2018-08-07T10:29:03Z</dc:date>
    </item>
  </channel>
</rss>

