<?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: Script creates file on second attempt of running in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Script-creates-file-on-second-attempt-of-running/m-p/297762#M62563</link>
    <description>&lt;P&gt;Did you forget a RUN at the last data step?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If the last procedure or data step code block does not have an explicit end then it is waiting for the next code to run that has a start of a procedure to terminate the code.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So the appearance after the second run is because the at the start of the second the first code actually detected the step boundary from the Data New.&lt;/P&gt;</description>
    <pubDate>Mon, 12 Sep 2016 14:25:27 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2016-09-12T14:25:27Z</dc:date>
    <item>
      <title>Script creates file on second attempt of running</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Script-creates-file-on-second-attempt-of-running/m-p/297760#M62561</link>
      <description>&lt;P&gt;I am relatively new to SAS Base. I have been wanting to write a script that does the following:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;Using a predefined ODBC connection, create a table based on the result of a simple&amp;nbsp;SELECT query. The result is copied in the WORK library&lt;/LI&gt;&lt;LI&gt;Copy the result of the above query (which is now a SAS dataset file in the temporary WORK folder) to a new destination.&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;This is my script (I have hidden the connection string and the path to destination folder):&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;LIBNAME DataMart ODBC noprompt= "MY_CONNECTION_STRING";
LIBNAME Autoload "PATH_TO_DESTINATION_FOLDER";
DATA NEW;
SET DataMart.ReportLG;
RUN;
PROC SQL;
CREATE TABLE ReportLG AS SELECT * FROM DataMart.ReportLG;
QUIT;

DATA autoload.ReportLG;
SET ReportLG;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;When I commit&amp;nbsp;this code&amp;nbsp;in SAS Base, it is only with my second attempt that I see the result file showing up in PATH_TO_DESTINATION_FOLDER.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Since I need to schedule this script so that the data remains updated, I need to know why the first commit does not do the job. What is it that I am doing wrong?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is the log I get in SAS Base with the first commit:&lt;/P&gt;&lt;PRE&gt;1    LIBNAME DataMart ODBC noprompt= XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX;

NOTE: Libref DATAMART was successfully assigned as follows:
      Engine:        ODBC
      Physical Name: actionbase
2    LIBNAME Autoload
2  ! "&lt;SPAN&gt;PATH_TO_DESTINATION_FOLDER&lt;/SPAN&gt;";
NOTE: Libref AUTOLOAD was successfully assigned as follows:
      Engine:        V9
      Physical Name:
      &lt;SPAN&gt;PATH_TO_DESTINATION_FOLDER&lt;/SPAN&gt;
3    DATA NEW;
4    SET DataMart.ReportLG;
5    RUN;

NOTE: There were 44 observations read from the data set DATAMART.ReportLG.
NOTE: The data set WORK.NEW has 44 observations and 33 variables.
NOTE: DATA statement used (Total process time):
      real time           0.02 seconds
      cpu time            0.01 seconds


6    PROC SQL;
7    CREATE TABLE ReportLG AS SELECT * FROM DataMart.ReportLG;
NOTE: Table WORK.REPORTLG created, with 44 rows and 33 columns.

8    QUIT;
NOTE: PROCEDURE SQL used (Total process time):
      real time           0.02 seconds
      cpu time            0.01 seconds


9
10   DATA autoload.ReportLG;
11   SET ReportLG;&lt;/PRE&gt;&lt;P&gt;And this is the log for the second commit which causes the file to be created:&lt;/P&gt;&lt;PRE&gt;12   LIBNAME DataMart ODBC noprompt= XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX;

NOTE: Libref DATAMART was successfully assigned as follows:
      Engine:        ODBC
      Physical Name: actionbase
13   LIBNAME Autoload
13 ! "&lt;SPAN&gt;PATH_TO_DESTINATION_FOLDER&lt;/SPAN&gt;";
NOTE: Libref AUTOLOAD was successfully assigned as follows:
      Engine:        V9
      Physical Name:
      &lt;SPAN&gt;PATH_TO_DESTINATION_FOLDER&lt;/SPAN&gt;

NOTE: There were 44 observations read from the data set WORK.REPORTLG.
NOTE: The data set AUTOLOAD.REPORTLG has 44 observations and 33 variables.
NOTE: DATA statement used (Total process time):
      real time           2:46.00
      cpu time            0.40 seconds


14   DATA NEW;
15   SET DataMart.ReportLG;
16   RUN;

NOTE: There were 44 observations read from the data set DATAMART.ReportLG.
NOTE: The data set WORK.NEW has 44 observations and 33 variables.
NOTE: DATA statement used (Total process time):
      real time           0.04 seconds
      cpu time            0.00 seconds


17   PROC SQL;
18   CREATE TABLE ReportLG AS SELECT * FROM DataMart.ReportLG;
NOTE: Table WORK.REPORTLG created, with 44 rows and 33 columns.

19   QUIT;
NOTE: PROCEDURE SQL used (Total process time):
      real time           0.02 seconds
      cpu time            0.03 seconds


20
21   DATA autoload.ReportLG;
22   SET ReportLG;&lt;/PRE&gt;</description>
      <pubDate>Mon, 12 Sep 2016 14:30:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Script-creates-file-on-second-attempt-of-running/m-p/297760#M62561</guid>
      <dc:creator>pedrammobedi</dc:creator>
      <dc:date>2016-09-12T14:30:37Z</dc:date>
    </item>
    <item>
      <title>Re: Script creates file on second attempt of running</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Script-creates-file-on-second-attempt-of-running/m-p/297761#M62562</link>
      <description>&lt;P&gt;You need to add a statement at the end of the program to get that last DATA step to run immediately:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;RUN;&lt;/P&gt;</description>
      <pubDate>Mon, 12 Sep 2016 14:24:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Script-creates-file-on-second-attempt-of-running/m-p/297761#M62562</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2016-09-12T14:24:52Z</dc:date>
    </item>
    <item>
      <title>Re: Script creates file on second attempt of running</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Script-creates-file-on-second-attempt-of-running/m-p/297762#M62563</link>
      <description>&lt;P&gt;Did you forget a RUN at the last data step?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If the last procedure or data step code block does not have an explicit end then it is waiting for the next code to run that has a start of a procedure to terminate the code.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So the appearance after the second run is because the at the start of the second the first code actually detected the step boundary from the Data New.&lt;/P&gt;</description>
      <pubDate>Mon, 12 Sep 2016 14:25:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Script-creates-file-on-second-attempt-of-running/m-p/297762#M62563</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2016-09-12T14:25:27Z</dc:date>
    </item>
    <item>
      <title>Re: Script creates file on second attempt of running</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Script-creates-file-on-second-attempt-of-running/m-p/297764#M62564</link>
      <description>Thank you so much!</description>
      <pubDate>Mon, 12 Sep 2016 14:34:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Script-creates-file-on-second-attempt-of-running/m-p/297764#M62564</guid>
      <dc:creator>pedrammobedi</dc:creator>
      <dc:date>2016-09-12T14:34:22Z</dc:date>
    </item>
  </channel>
</rss>

