<?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: Database Query and the Specific File extraction in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Database-Query-and-the-Specific-File-extraction/m-p/542192#M7505</link>
    <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/266105"&gt;@dwilliams1&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;&amp;nbsp;I want to do the following:&lt;/P&gt;
&lt;P&gt;1) Connect to a MS Access database (Successfully done)&lt;/P&gt;
&lt;P&gt;2) Create data table of all runs as read from specific table in database (Successfully done)&lt;/P&gt;
&lt;P&gt;3) Create data table of the 10 most recent runs (Successfully done)&lt;/P&gt;
&lt;P&gt;4) Using proc sql, create a space deliminated list of these runs (Successfully done)&lt;/P&gt;
&lt;P&gt;5) Loop over the list and create data tables in the work directory of the most recent 10 runs.&amp;nbsp; (Fails Miserably)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here's a snippet of the failed part&amp;nbsp; from the log:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;319 data _all_; /* Fails miserable */&lt;/P&gt;
&lt;P&gt;320 set&lt;/P&gt;
&lt;P&gt;321 %do i=1 %to %word_count2(&amp;amp;ParamList);&lt;/P&gt;
&lt;P&gt;ERROR: The %DO statement is not valid in open code.&lt;/P&gt;
&lt;P&gt;322 &amp;amp;ParamList&lt;/P&gt;
&lt;P&gt;323 %end;&lt;/P&gt;
&lt;P&gt;ERROR: The %END statement is not valid in open code.&lt;/P&gt;
&lt;P&gt;324 ;&lt;/P&gt;
&lt;P&gt;325 run;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;The message "ERROR: The %DO statement is not valid in open code." means that you need to create a proper macro using the&lt;/P&gt;
&lt;P&gt;%macro to %mend statements to define macro code and then execute the defined macro. Some of the later versions of SAS support&lt;/P&gt;
&lt;P&gt;%do in "open code", which means outside of a %macro/%mend code block, but apparently not yours.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If your &amp;amp;parmlist contains space delimited proper library.dataset names then the %do is not needed as the set statement accepts multiple data sets. Your code, as written would likely have generated multiple copies of each data set in your list.&lt;/P&gt;
&lt;P&gt;Not that the following will make a particularly useful data set it demonstrates use of SET statement with multiple sets:&lt;/P&gt;
&lt;PRE&gt;data work.junk;
   set 
      sashelp.class
      sashelp.cars
   ;
run;&lt;/PRE&gt;
&lt;P&gt;If your PARAMLIST variable looks like proper library dataset names, or all of the sets are in the WORK library then&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;data _all_;
   set 
      &amp;amp;Paramlist
   ;
run;&lt;/PRE&gt;
&lt;P&gt;Should work.&lt;/P&gt;</description>
    <pubDate>Mon, 11 Mar 2019 19:57:04 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2019-03-11T19:57:04Z</dc:date>
    <item>
      <title>Database Query and the Specific File extraction</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Database-Query-and-the-Specific-File-extraction/m-p/542090#M7475</link>
      <description>&lt;P&gt;&amp;nbsp;I want to do the following:&lt;/P&gt;&lt;P&gt;1) Connect to a MS Access database (Successfully done)&lt;/P&gt;&lt;P&gt;2) Create data table of all runs as read from specific table in database (Successfully done)&lt;/P&gt;&lt;P&gt;3) Create data table of the 10 most recent runs (Successfully done)&lt;/P&gt;&lt;P&gt;4) Using proc sql, create a space deliminated list of these runs (Successfully done)&lt;/P&gt;&lt;P&gt;5) Loop over the list and create data tables in the work directory of the most recent 10 runs.&amp;nbsp; (Fails Miserably)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here's a snippet of the failed part&amp;nbsp; from the log:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;319 data _all_; /* Fails miserable */&lt;/P&gt;&lt;P&gt;320 set&lt;/P&gt;&lt;P&gt;321 %do i=1 %to %word_count2(&amp;amp;ParamList);&lt;/P&gt;&lt;P&gt;ERROR: The %DO statement is not valid in open code.&lt;/P&gt;&lt;P&gt;322 &amp;amp;ParamList&lt;/P&gt;&lt;P&gt;323 %end;&lt;/P&gt;&lt;P&gt;ERROR: The %END statement is not valid in open code.&lt;/P&gt;&lt;P&gt;324 ;&lt;/P&gt;&lt;P&gt;325 run;&lt;/P&gt;</description>
      <pubDate>Mon, 11 Mar 2019 15:58:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Database-Query-and-the-Specific-File-extraction/m-p/542090#M7475</guid>
      <dc:creator>dwilliams1</dc:creator>
      <dc:date>2019-03-11T15:58:41Z</dc:date>
    </item>
    <item>
      <title>Re: Database Query and the Specific File extraction</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Database-Query-and-the-Specific-File-extraction/m-p/542091#M7476</link>
      <description>&lt;P&gt;Attached is the sas code.&amp;nbsp; Thought it was included initially.&lt;/P&gt;</description>
      <pubDate>Mon, 11 Mar 2019 16:00:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Database-Query-and-the-Specific-File-extraction/m-p/542091#M7476</guid>
      <dc:creator>dwilliams1</dc:creator>
      <dc:date>2019-03-11T16:00:53Z</dc:date>
    </item>
    <item>
      <title>Re: Database Query and the Specific File extraction</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Database-Query-and-the-Specific-File-extraction/m-p/542192#M7505</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/266105"&gt;@dwilliams1&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;&amp;nbsp;I want to do the following:&lt;/P&gt;
&lt;P&gt;1) Connect to a MS Access database (Successfully done)&lt;/P&gt;
&lt;P&gt;2) Create data table of all runs as read from specific table in database (Successfully done)&lt;/P&gt;
&lt;P&gt;3) Create data table of the 10 most recent runs (Successfully done)&lt;/P&gt;
&lt;P&gt;4) Using proc sql, create a space deliminated list of these runs (Successfully done)&lt;/P&gt;
&lt;P&gt;5) Loop over the list and create data tables in the work directory of the most recent 10 runs.&amp;nbsp; (Fails Miserably)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here's a snippet of the failed part&amp;nbsp; from the log:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;319 data _all_; /* Fails miserable */&lt;/P&gt;
&lt;P&gt;320 set&lt;/P&gt;
&lt;P&gt;321 %do i=1 %to %word_count2(&amp;amp;ParamList);&lt;/P&gt;
&lt;P&gt;ERROR: The %DO statement is not valid in open code.&lt;/P&gt;
&lt;P&gt;322 &amp;amp;ParamList&lt;/P&gt;
&lt;P&gt;323 %end;&lt;/P&gt;
&lt;P&gt;ERROR: The %END statement is not valid in open code.&lt;/P&gt;
&lt;P&gt;324 ;&lt;/P&gt;
&lt;P&gt;325 run;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;The message "ERROR: The %DO statement is not valid in open code." means that you need to create a proper macro using the&lt;/P&gt;
&lt;P&gt;%macro to %mend statements to define macro code and then execute the defined macro. Some of the later versions of SAS support&lt;/P&gt;
&lt;P&gt;%do in "open code", which means outside of a %macro/%mend code block, but apparently not yours.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If your &amp;amp;parmlist contains space delimited proper library.dataset names then the %do is not needed as the set statement accepts multiple data sets. Your code, as written would likely have generated multiple copies of each data set in your list.&lt;/P&gt;
&lt;P&gt;Not that the following will make a particularly useful data set it demonstrates use of SET statement with multiple sets:&lt;/P&gt;
&lt;PRE&gt;data work.junk;
   set 
      sashelp.class
      sashelp.cars
   ;
run;&lt;/PRE&gt;
&lt;P&gt;If your PARAMLIST variable looks like proper library dataset names, or all of the sets are in the WORK library then&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;data _all_;
   set 
      &amp;amp;Paramlist
   ;
run;&lt;/PRE&gt;
&lt;P&gt;Should work.&lt;/P&gt;</description>
      <pubDate>Mon, 11 Mar 2019 19:57:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Database-Query-and-the-Specific-File-extraction/m-p/542192#M7505</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2019-03-11T19:57:04Z</dc:date>
    </item>
  </channel>
</rss>

