<?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: Do Loop in Proc SQL in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Do-Loop-in-Proc-SQL/m-p/295248#M61683</link>
    <description>&lt;P&gt;What OS and what SAS version do you use ?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Try change a line to:&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp;%str(proc sql;); &amp;nbsp; &amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;instead: proc sql;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have tried using %do ... %end in a proc sql, similar to your code, and had no ERROR like your&lt;/P&gt;</description>
    <pubDate>Tue, 30 Aug 2016 16:29:58 GMT</pubDate>
    <dc:creator>Shmuel</dc:creator>
    <dc:date>2016-08-30T16:29:58Z</dc:date>
    <item>
      <title>Do Loop in Proc SQL</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Do-Loop-in-Proc-SQL/m-p/295235#M61677</link>
      <description>&lt;P&gt;Hello:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have 6 separate datasets. I want to upload each of&amp;nbsp;these datasets&amp;nbsp;and create 6 different&amp;nbsp;oracle tables. I have a macro in which I am attempting to execute Do loop in Proc SQL:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;%let&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; count = 6;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;libname&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt; lob &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="2"&gt;&lt;FONT color="#800080" face="Courier New" size="2"&gt;&lt;FONT color="#800080" face="Courier New" size="2"&gt;'/xxx/xxx/xxx/Data'&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;libname&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt; khalke oracle user=&amp;amp;xxx password=&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="2"&gt;&lt;FONT color="#800080" face="Courier New" size="2"&gt;&lt;FONT color="#800080" face="Courier New" size="2"&gt;"&amp;amp;xxx"&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt; path=&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="2"&gt;&lt;FONT color="#800080" face="Courier New" size="2"&gt;&lt;FONT color="#800080" face="Courier New" size="2"&gt;"&amp;amp;xxx"&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt; schema=&amp;amp;xxx;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;STRONG&gt;%Macro&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt; &lt;STRONG&gt;&lt;I&gt;fileupload&lt;/I&gt;&lt;/STRONG&gt;;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;proc sql;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;%do&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt; i = &lt;/FONT&gt;&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;1&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/STRONG&gt; &lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;%to&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt; &amp;amp;count;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;create table khalke.test_xxx_d209file_T&amp;amp;count as&lt;/P&gt;&lt;P&gt;select *&lt;/P&gt;&lt;P&gt;from lob.test_xxx_d209file&amp;amp;count&lt;/P&gt;&lt;P&gt;order by actnmbr;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;%end&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;STRONG&gt;%mend&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;%&lt;STRONG&gt;&lt;I&gt;fileupload&lt;/I&gt;&lt;/STRONG&gt;;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;However, I am getting the following error&amp;nbsp;message:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%let count = 6;&lt;/P&gt;&lt;P&gt;libname lob '/xxx/xxx/xxx/Data';&lt;/P&gt;&lt;P&gt;NOTE: Libref LOB was successfully assigned as follows:&lt;/P&gt;&lt;P&gt;Engine: V9&lt;/P&gt;&lt;P&gt;Physical Name: /xxx/xxx/xxx/Data&lt;/P&gt;&lt;P&gt;libname khalke oracle user=&amp;amp;xxx password="&amp;amp;xxx" path="&amp;amp;xxx"&lt;/P&gt;&lt;P&gt;! schema=&amp;amp;xxx;&lt;/P&gt;&lt;P&gt;NOTE: Libref KHALKE was successfully assigned as follows:&lt;/P&gt;&lt;P&gt;Engine: ORACLE&lt;/P&gt;&lt;P&gt;Physical Name: WFPROD&lt;/P&gt;&lt;P&gt;%Macro fileupload;&lt;/P&gt;&lt;P&gt;proc sql;&lt;/P&gt;&lt;P&gt;%do i = 1 %to &amp;amp;count;&lt;/P&gt;&lt;P&gt;create table khalke.test_xxxx_d209file_T&amp;amp;count as&lt;/P&gt;&lt;P&gt;select *&lt;/P&gt;&lt;P&gt;from lob.test_xxxx_d209file&amp;amp;count&lt;/P&gt;&lt;P&gt;order by actnmbr;&lt;/P&gt;&lt;P&gt;%end;&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;P&gt;%mend;&lt;/P&gt;&lt;P&gt;ERROR: There were 1 unclosed %DO statements. The macro FILEUPLOAD will not be compiled.&lt;/P&gt;&lt;P&gt;ERROR: A dummy macro will be compiled.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%fileupload;&lt;/P&gt;&lt;P&gt;-&lt;/P&gt;&lt;P&gt;180&lt;/P&gt;&lt;P&gt;WARNING: Apparent invocation of macro FILEUPLOAD not resolved.&lt;/P&gt;&lt;P&gt;ERROR 180-322: Statement is not valid or it is used out of proper order.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 30 Aug 2016 16:00:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Do-Loop-in-Proc-SQL/m-p/295235#M61677</guid>
      <dc:creator>kalkebulan</dc:creator>
      <dc:date>2016-08-30T16:00:16Z</dc:date>
    </item>
    <item>
      <title>Re: Do Loop in Proc SQL</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Do-Loop-in-Proc-SQL/m-p/295244#M61680</link>
      <description>&lt;P&gt;This code looks fine.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;There must be complications, like another macro that contains an unclosed %DO block that also contains this code.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;To help in the diagnosis, try changing the %MEND statement so it specifies which macro definition is ending:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%mend fileupload;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;That can only help, never hurts.&lt;/P&gt;</description>
      <pubDate>Tue, 30 Aug 2016 16:19:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Do-Loop-in-Proc-SQL/m-p/295244#M61680</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2016-08-30T16:19:40Z</dc:date>
    </item>
    <item>
      <title>Re: Do Loop in Proc SQL</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Do-Loop-in-Proc-SQL/m-p/295248#M61683</link>
      <description>&lt;P&gt;What OS and what SAS version do you use ?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Try change a line to:&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp;%str(proc sql;); &amp;nbsp; &amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;instead: proc sql;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have tried using %do ... %end in a proc sql, similar to your code, and had no ERROR like your&lt;/P&gt;</description>
      <pubDate>Tue, 30 Aug 2016 16:29:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Do-Loop-in-Proc-SQL/m-p/295248#M61683</guid>
      <dc:creator>Shmuel</dc:creator>
      <dc:date>2016-08-30T16:29:58Z</dc:date>
    </item>
    <item>
      <title>Re: Do Loop in Proc SQL</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Do-Loop-in-Proc-SQL/m-p/295308#M61701</link>
      <description>&lt;P&gt;You may want to reconsider this code snippet:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;create table khalke.test_xxx_d209file_T&amp;amp;count as

select *

from lob.test_xxx_d209file&amp;amp;count
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;That is creating the same file count times (and may cause some timing issues)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I suspect that you meant&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;create table khalke.test_xxx_d209file_T&amp;amp;i as

select *

from lob.test_xxx_d209file&amp;amp;i&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;to use the i counter to change table names.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Run your code with OPTIONS MPRINT;&lt;/P&gt;
&lt;P&gt;before calling the macro. The log will likely provide better information as to where the problem is occuring.&lt;/P&gt;</description>
      <pubDate>Tue, 30 Aug 2016 20:13:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Do-Loop-in-Proc-SQL/m-p/295308#M61701</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2016-08-30T20:13:01Z</dc:date>
    </item>
  </channel>
</rss>

