<?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: Conditional PROC SQL in SAS Data Management</title>
    <link>https://communities.sas.com/t5/SAS-Data-Management/Conditional-PROC-SQL/m-p/638355#M19107</link>
    <description>*Turns out, with a few improvements (like "&amp;lt;&amp;gt;" replaced by "ne"), "the original code" was working.</description>
    <pubDate>Wed, 08 Apr 2020 16:38:47 GMT</pubDate>
    <dc:creator>RicHen</dc:creator>
    <dc:date>2020-04-08T16:38:47Z</dc:date>
    <item>
      <title>Conditional PROC SQL</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Conditional-PROC-SQL/m-p/638110#M19093</link>
      <description>&lt;P&gt;Hi there!&lt;/P&gt;&lt;P&gt;I am trying to call a PROC SQL or another based on an input variable.&lt;/P&gt;&lt;P&gt;My input variable is like YYYYMM, and if MM is equal to 01 then I do a new table else I need to merge with the table from the month before.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is there anyway to do this?&lt;/P&gt;&lt;P&gt;I tried but I keep failing it doesn't create a table.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks in advance.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The code I tried was something like:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;%let month=%substr(&amp;amp;delta,5,2);
%macro january;
proc sql;
	create table WORK.RH_SOLV_RECEITA_EMITIDA_&amp;amp;delta as 
 	select *
		from WORK.SOLV_RECEITA_EMITIDA_MES;
quit;
%mend janeiro; 
%macro outros;
proc sql;
	create table WORK.RH_SOLV_RECEITA_EMITIDA_&amp;amp;delta as 
	select * FROM WORK.SOLV_RECEITA_EMITIDA_OLD_MES
	outer union corr 
	select * FROM WORK.SOLV_RECEITA_EMITIDA_MES;
quit;
%mend outros;
data _null_;
	if &amp;amp;month = '01' then call execute('%janeiro');
	if &amp;amp;delta &amp;lt;&amp;gt; '01' then call execute('%outros');
run;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 07 Apr 2020 15:34:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Conditional-PROC-SQL/m-p/638110#M19093</guid>
      <dc:creator>RicHen</dc:creator>
      <dc:date>2020-04-07T15:34:00Z</dc:date>
    </item>
    <item>
      <title>Re: Conditional PROC SQL</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Conditional-PROC-SQL/m-p/638113#M19094</link>
      <description>&lt;P&gt;If macro variable delta contains this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let delta=202001;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Then this&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if &amp;amp;delta &amp;lt;&amp;gt; '01'&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;resolves to&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if 202001 &amp;lt;&amp;gt; '01'&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;which will always be false.&lt;/P&gt;
&lt;P&gt;The data step will convert your number to a string on its own, but that won't help either.&lt;/P&gt;</description>
      <pubDate>Tue, 07 Apr 2020 15:40:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Conditional-PROC-SQL/m-p/638113#M19094</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-04-07T15:40:37Z</dc:date>
    </item>
    <item>
      <title>Re: Conditional PROC SQL</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Conditional-PROC-SQL/m-p/638124#M19095</link>
      <description>&lt;P&gt;delta is in the text format, never the less I changed the data to&lt;/P&gt;&lt;PRE&gt;%let month=%substr(&amp;amp;delta,5,2);
%macro january;
proc sql;
	create table WORK.RH_SOLV_RECEITA_EMITIDA_&amp;amp;delta as 
 	select *
		from WORK.SOLV_RECEITA_EMITIDA_MES;
quit;
%mend january; 
%macro outros;
proc sql;
	create table WORK.RH_SOLV_RECEITA_EMITIDA_&amp;amp;delta as 
	select * FROM WORK.SOLV_RECEITA_EMITIDA_OLD_MES
	outer union corr 
	select * FROM WORK.SOLV_RECEITA_EMITIDA_MES;
quit;
%mend outros;
data _null_;
	if &amp;amp;month = 1 then call execute('%january');
	if &amp;amp;month &amp;lt;&amp;gt; 1 then call execute('%outros');
run;&lt;/PRE&gt;&lt;P&gt;and still it doesn't create a table.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 07 Apr 2020 16:12:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Conditional-PROC-SQL/m-p/638124#M19095</guid>
      <dc:creator>RicHen</dc:creator>
      <dc:date>2020-04-07T16:12:36Z</dc:date>
    </item>
    <item>
      <title>Re: Conditional PROC SQL</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Conditional-PROC-SQL/m-p/638128#M19096</link>
      <description>&lt;P&gt;Maxim 2: Read the Log. &amp;lt;&amp;gt; is not interpreted by the data step compiler in the way you think.&lt;/P&gt;
&lt;P&gt;Start &amp;nbsp;simple, and then expand on this code:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro january;
%put january executing;
%mend january; 
%macro outros;
%put outros executing;
%mend outros;

%let delta=202001;
%let month=%substr(&amp;amp;delta,5,2);
data _null_;
	if &amp;amp;month = 1 then call execute('%january');
	if &amp;amp;month ne 1 then call execute('%outros'); /* use the proper operator for not equals */
run;

%let delta=202002;
%let month=%substr(&amp;amp;delta,5,2);
data _null_;
	if &amp;amp;month = 1 then call execute('%january');
	if &amp;amp;month ne 1 then call execute('%outros');
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 07 Apr 2020 16:20:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Conditional-PROC-SQL/m-p/638128#M19096</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-04-07T16:20:16Z</dc:date>
    </item>
    <item>
      <title>Re: Conditional PROC SQL</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Conditional-PROC-SQL/m-p/638130#M19097</link>
      <description>&lt;P&gt;Will do.&lt;/P&gt;&lt;P&gt;Back on the topic when I have more news.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for your support&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/11562"&gt;@Kurt_Bremser&lt;/a&gt;.&lt;/P&gt;</description>
      <pubDate>Tue, 07 Apr 2020 16:31:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Conditional-PROC-SQL/m-p/638130#M19097</guid>
      <dc:creator>RicHen</dc:creator>
      <dc:date>2020-04-07T16:31:00Z</dc:date>
    </item>
    <item>
      <title>Re: Conditional PROC SQL</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Conditional-PROC-SQL/m-p/638151#M19098</link>
      <description>&lt;P&gt;This line has an obviously TRUE test condition.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;	if &amp;amp;month &amp;lt;&amp;gt; 1 then call execute('%outros');&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;It really does not matter what value MONTH has since the MAXimum value of 1 or &amp;amp;MONTH is never going to be zero or missing the test will always be TRUE.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Perhaps you are trying to test if &amp;amp;MONTH is NOT EQUAL to 1?&amp;nbsp; If so then use an appropriate operator for that.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 07 Apr 2020 18:37:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Conditional-PROC-SQL/m-p/638151#M19098</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2020-04-07T18:37:25Z</dc:date>
    </item>
    <item>
      <title>Re: Conditional PROC SQL</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Conditional-PROC-SQL/m-p/638349#M19106</link>
      <description>&lt;P&gt;So I copied the code&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/11562"&gt;@Kurt_Bremser&lt;/a&gt;&amp;nbsp;gave me and pasted in the project.&lt;/P&gt;&lt;P&gt;Result, didn't work.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Copied it into a new project, worked perfectly.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Closed and ran the project again and now the code works.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Turns out, with a few improvements (like "&amp;lt;&amp;gt;" replaced by "ne"), was working.&lt;/P&gt;&lt;P&gt;It was a bug in the project which got solved by a restart.&amp;nbsp;&lt;span class="lia-unicode-emoji" title=":expressionless_face:"&gt;😑&lt;/span&gt;&amp;nbsp;&lt;span class="lia-unicode-emoji" title=":face_with_rolling_eyes:"&gt;🙄&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for your time&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/11562"&gt;@Kurt_Bremser&lt;/a&gt;&amp;nbsp; and&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom&lt;/a&gt;.&lt;/P&gt;</description>
      <pubDate>Wed, 08 Apr 2020 16:07:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Conditional-PROC-SQL/m-p/638349#M19106</guid>
      <dc:creator>RicHen</dc:creator>
      <dc:date>2020-04-08T16:07:39Z</dc:date>
    </item>
    <item>
      <title>Re: Conditional PROC SQL</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Conditional-PROC-SQL/m-p/638355#M19107</link>
      <description>*Turns out, with a few improvements (like "&amp;lt;&amp;gt;" replaced by "ne"), "the original code" was working.</description>
      <pubDate>Wed, 08 Apr 2020 16:38:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Conditional-PROC-SQL/m-p/638355#M19107</guid>
      <dc:creator>RicHen</dc:creator>
      <dc:date>2020-04-08T16:38:47Z</dc:date>
    </item>
    <item>
      <title>Re: Conditional PROC SQL</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Conditional-PROC-SQL/m-p/638604#M19116</link>
      <description>&lt;P&gt;You may have had an "Autoexec" process flow in your project that caused this.&lt;/P&gt;</description>
      <pubDate>Thu, 09 Apr 2020 06:48:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Conditional-PROC-SQL/m-p/638604#M19116</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-04-09T06:48:47Z</dc:date>
    </item>
    <item>
      <title>Re: Conditional PROC SQL</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Conditional-PROC-SQL/m-p/638727#M19121</link>
      <description>Possibly... I had a lot of tryouts before I reached this code.</description>
      <pubDate>Thu, 09 Apr 2020 16:37:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Conditional-PROC-SQL/m-p/638727#M19121</guid>
      <dc:creator>RicHen</dc:creator>
      <dc:date>2020-04-09T16:37:48Z</dc:date>
    </item>
  </channel>
</rss>

