<?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: Using Macros in SQL FROM Statement in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Using-Macros-in-SQL-FROM-Statement/m-p/761472#M240974</link>
    <description>&lt;P&gt;When writing a single statement that spans multiple lines put the semi-colon that ends it on its own line.&amp;nbsp; Like the END in a DO/END block.&lt;/P&gt;
&lt;P&gt;Then you are less likely to forget it or insert extra ones.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;create table name1&amp;amp;&amp;amp;file&amp;amp;n as
  select *
  from name2&amp;amp;&amp;amp;file&amp;amp;n a
  inner join input.&amp;amp;&amp;amp;file&amp;amp;n.._base b
     on a.ssn = b.&amp;amp;pat_ssn
    and a.record_id= b.record_id
;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 13 Aug 2021 17:03:40 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2021-08-13T17:03:40Z</dc:date>
    <item>
      <title>Using Macros in SQL FROM Statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-Macros-in-SQL-FROM-Statement/m-p/761458#M240964</link>
      <description>&lt;P&gt;Hello!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm attempting to do an inner join on multiple tables. This code is within a %DO loop with n as the variable.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%let file1=datahave1;&lt;/P&gt;&lt;P&gt;%let file2=datahave2;&lt;/P&gt;&lt;P&gt;.&lt;/P&gt;&lt;P&gt;.&lt;/P&gt;&lt;P&gt;.&lt;/P&gt;&lt;P&gt;%let file10=datahave10;&lt;/P&gt;&lt;P&gt;%let numoffiles=10;&lt;/P&gt;&lt;P&gt;libname input "path";&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%macro formatex;&lt;BR /&gt;%do n=1 %to &amp;amp;numoffiles;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc sql;&lt;BR /&gt;create table name1&amp;amp;&amp;amp;file&amp;amp;n as&lt;BR /&gt;select *&lt;BR /&gt;from name2&amp;amp;&amp;amp;file&amp;amp;n a inner join input.&amp;amp;&amp;amp;file&amp;amp;n.._base b&lt;BR /&gt;on a.ssn = b.&amp;amp;pat_ssn and a.record_id= b.record_id&lt;BR /&gt;quit;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%end;&lt;BR /&gt;%mend;&lt;BR /&gt;%formatex;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Right now it just runs the SQL step forever. I'm new to macros, so any help would be greatly appreciated!&lt;/P&gt;</description>
      <pubDate>Fri, 13 Aug 2021 16:01:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-Macros-in-SQL-FROM-Statement/m-p/761458#M240964</guid>
      <dc:creator>smg3141</dc:creator>
      <dc:date>2021-08-13T16:01:01Z</dc:date>
    </item>
    <item>
      <title>Re: Using Macros in SQL FROM Statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-Macros-in-SQL-FROM-Statement/m-p/761467#M240970</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/324306"&gt;@smg3141&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/324306"&gt;@smg3141&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;on a.ssn = b.&amp;amp;pat_ssn and a.record_id= b.record_id&lt;FONT size="5" color="#FF0000"&gt;&lt;STRONG&gt;;&lt;/STRONG&gt;&lt;/FONT&gt;&lt;BR /&gt;quit;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;Right now it just runs the SQL step forever.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;This is because you missed the semicolon that I've inserted in red above.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The RUN statement can be deleted. PROC SQL doesn't need it.&lt;/P&gt;</description>
      <pubDate>Fri, 13 Aug 2021 16:48:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-Macros-in-SQL-FROM-Statement/m-p/761467#M240970</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2021-08-13T16:48:26Z</dc:date>
    </item>
    <item>
      <title>Re: Using Macros in SQL FROM Statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-Macros-in-SQL-FROM-Statement/m-p/761468#M240971</link>
      <description>Doh! What a rookie mistake. Thank you!</description>
      <pubDate>Fri, 13 Aug 2021 16:52:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-Macros-in-SQL-FROM-Statement/m-p/761468#M240971</guid>
      <dc:creator>smg3141</dc:creator>
      <dc:date>2021-08-13T16:52:46Z</dc:date>
    </item>
    <item>
      <title>Re: Using Macros in SQL FROM Statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-Macros-in-SQL-FROM-Statement/m-p/761472#M240974</link>
      <description>&lt;P&gt;When writing a single statement that spans multiple lines put the semi-colon that ends it on its own line.&amp;nbsp; Like the END in a DO/END block.&lt;/P&gt;
&lt;P&gt;Then you are less likely to forget it or insert extra ones.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;create table name1&amp;amp;&amp;amp;file&amp;amp;n as
  select *
  from name2&amp;amp;&amp;amp;file&amp;amp;n a
  inner join input.&amp;amp;&amp;amp;file&amp;amp;n.._base b
     on a.ssn = b.&amp;amp;pat_ssn
    and a.record_id= b.record_id
;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 13 Aug 2021 17:03:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-Macros-in-SQL-FROM-Statement/m-p/761472#M240974</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-08-13T17:03:40Z</dc:date>
    </item>
  </channel>
</rss>

