<?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 Do While Loop in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Proc-SQL-Do-While-Loop/m-p/430142#M281563</link>
    <description>&lt;P&gt;What is the question you are trying to ask?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you are looking for where the errors lie, here is a list for starters.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The %MACRO statement is missing a semicolon.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The final %END statement is also missing a semicolon.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The final PROC SQL is missing a QUIT statement.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The first PROC SQL has an extra semicolon.&amp;nbsp; (The WHERE clause should be part of the SELECT statement, not a separate statement.)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Calling the macro with "Low" as the value for &amp;amp;RL gives you incorrect table names, such as &amp;nbsp;"1"Low" Table1Name"n&amp;nbsp; Given that you call the macro without quotes around "Low", you would have to change the WHERE clause:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Where t1.Field1 = "&amp;amp;RL.";&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What in the world is Libref1?&amp;nbsp; Do&amp;nbsp; you mean t1, such as t1.Field1 ?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Of course, there may be more.&amp;nbsp; That's all that jumped out at first glance.&lt;/P&gt;</description>
    <pubDate>Tue, 23 Jan 2018 20:10:06 GMT</pubDate>
    <dc:creator>Astounding</dc:creator>
    <dc:date>2018-01-23T20:10:06Z</dc:date>
    <item>
      <title>Proc SQL Do While Loop</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-SQL-Do-While-Loop/m-p/430119#M281562</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm interested in creating a do loop while a macro variable shows there is a error grater than 0.&lt;/P&gt;&lt;P&gt;I'm setting the macro variable as the result of a proc sql query.&lt;/P&gt;&lt;P&gt;here what my code look like:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;%Macro&lt;/STRONG&gt; MacroSample(RL=)&lt;/P&gt;&lt;P&gt;%let TableName1 = "1&amp;amp;RL. Table1Name"n;&lt;/P&gt;&lt;P&gt;%let TableName2 = "2&amp;amp;RL. Table2Name"n;&lt;/P&gt;&lt;P&gt;PROC SQL;&lt;/P&gt;&lt;P&gt;CREATE TABLE WORK.&amp;amp;tablename2. AS&lt;/P&gt;&lt;P&gt;SELECT&lt;/P&gt;&lt;P&gt;(SUM(t1.'Connection Difference'n)) AS 'Connection Difference'n&lt;/P&gt;&lt;P&gt;&amp;nbsp;Into : CheckFlag&lt;/P&gt;&lt;P&gt;FROM WORK.&amp;amp;tablename1. t1;&lt;/P&gt;&lt;P&gt;Where t1.Field1 = &amp;amp;RL.;&lt;/P&gt;&lt;P&gt;%Let CheckFlag = &amp;amp;CheckFlag;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;QUIT;&lt;/P&gt;&lt;P&gt;/* Macro Begins if Connection Mismaches Fails */&lt;/P&gt;&lt;P&gt;%Do %while (&amp;amp;CheckFlag. &amp;gt;&lt;STRONG&gt;0&lt;/STRONG&gt;);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;/* Begin loop by updating the original table until sum of error is 0*/&lt;/P&gt;&lt;P&gt;PROC SQL;&lt;/P&gt;&lt;P&gt;CREATE TABLE WORK.&amp;amp;tablename1. AS&lt;/P&gt;&lt;P&gt;SELECT&lt;/P&gt;&lt;P&gt;Libref1.Field1,&lt;/P&gt;&lt;P&gt;Libref1.Field2&lt;/P&gt;&lt;P&gt;Calculation1 AS 'Connection Difference'n&lt;/P&gt;&lt;P&gt;FROM WORK.&amp;amp;TableName1. t1;&lt;/P&gt;&lt;P&gt;&amp;nbsp;QUIT;&lt;/P&gt;&lt;P&gt;　CREATE TABLE WORK.&amp;amp;tablename2. AS&lt;/P&gt;&lt;P&gt;SELECT&lt;/P&gt;&lt;P&gt;(SUM(t1.'Connection Difference'n)) AS 'Connection Difference'n&lt;/P&gt;&lt;P&gt;&amp;nbsp;Into : CheckFlag&lt;/P&gt;&lt;P&gt;FROM WORK.&amp;amp;tablename1. t1;&lt;/P&gt;&lt;P&gt;%Let CheckFlag = &amp;amp;CheckFlag;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%End&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;%Mend&lt;/STRONG&gt; MacroSample;&lt;/P&gt;&lt;P&gt;%&lt;STRONG&gt;&lt;EM&gt;MacroSample&lt;/EM&gt;&lt;/STRONG&gt;(RL= "Low")&lt;/P&gt;</description>
      <pubDate>Tue, 23 Jan 2018 18:53:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-SQL-Do-While-Loop/m-p/430119#M281562</guid>
      <dc:creator>RickGNYC</dc:creator>
      <dc:date>2018-01-23T18:53:19Z</dc:date>
    </item>
    <item>
      <title>Re: Proc SQL Do While Loop</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-SQL-Do-While-Loop/m-p/430142#M281563</link>
      <description>&lt;P&gt;What is the question you are trying to ask?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you are looking for where the errors lie, here is a list for starters.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The %MACRO statement is missing a semicolon.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The final %END statement is also missing a semicolon.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The final PROC SQL is missing a QUIT statement.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The first PROC SQL has an extra semicolon.&amp;nbsp; (The WHERE clause should be part of the SELECT statement, not a separate statement.)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Calling the macro with "Low" as the value for &amp;amp;RL gives you incorrect table names, such as &amp;nbsp;"1"Low" Table1Name"n&amp;nbsp; Given that you call the macro without quotes around "Low", you would have to change the WHERE clause:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Where t1.Field1 = "&amp;amp;RL.";&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What in the world is Libref1?&amp;nbsp; Do&amp;nbsp; you mean t1, such as t1.Field1 ?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Of course, there may be more.&amp;nbsp; That's all that jumped out at first glance.&lt;/P&gt;</description>
      <pubDate>Tue, 23 Jan 2018 20:10:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-SQL-Do-While-Loop/m-p/430142#M281563</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2018-01-23T20:10:06Z</dc:date>
    </item>
  </channel>
</rss>

