<?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: append data to sql data in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/append-data-to-sql-data/m-p/881657#M348363</link>
    <description>&lt;P&gt;The schema is needed in LIBNAME statement. For pass through the tablespace follows the FROM statement and then a period + table name:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;proc sql;
connect to SQLSVR as mydb (Datasrc="EDWHDSST" AUTHDOMAIN="SQLSRVAuth" );
execute (SELECT * FROM dbo.TABSQL) by sqlsvr;
disconnect from sqlsvr;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Wed, 21 Jun 2023 08:19:15 GMT</pubDate>
    <dc:creator>HenryKobus</dc:creator>
    <dc:date>2023-06-21T08:19:15Z</dc:date>
    <item>
      <title>append data to sql data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/append-data-to-sql-data/m-p/881643#M348355</link>
      <description>&lt;P&gt;Good morning. A proc append in a SQL data library takes a very long time to append data. However, the same data on a basic sas library takes a few seconds. I report the 2 example logs.&lt;/P&gt;
&lt;P&gt;I'm asking for suggestions on which method is better to hang data on a Sql Server data library from sas:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;DIV&gt;proc append base = LIB_SAS.TAB1 data = backup.WXGC21K force nowarn;&lt;/DIV&gt;
&lt;DIV&gt;run;&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;NOTE: Appending BACKUP.WXGC21K a EDWH_ODS.TAB1.&lt;/DIV&gt;
&lt;DIV&gt;NOTE: FORCE is specified, so dropping/truncating will occur.&lt;/DIV&gt;
&lt;DIV&gt;NOTE: There were 16945246 observations read from the data set BACKUP.WXGC21K.&lt;/DIV&gt;
&lt;DIV&gt;NOTE: 16945246 observations added.&lt;/DIV&gt;
&lt;DIV&gt;NOTE: The data set EDWH_ODS.TAB1 has 16945246 observations and 4 variables.&lt;/DIV&gt;
&lt;DIV&gt;NOTE: PROCEDURE APPEND ha utilizzato (tempo totale di elaborazione):&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; real time&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;14.97 seconds&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN&gt;-------------------------------------------------------------------------------------------------&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN&gt; &amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;proc append base = LIB_SQL.TAB1 data = work.WU98D7R force nowarn;&lt;/DIV&gt;
&lt;DIV&gt;run;&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;NOTE: Appending WORK.WU98D7R a LIB_SQL.TAB1.&lt;/DIV&gt;
&lt;DIV&gt;NOTE: FORCE is specified, so dropping/truncating will occur.&lt;/DIV&gt;
&lt;DIV&gt;NOTE: There were 16945246 observations read from the data set WORK.WU98D7R.&lt;/DIV&gt;
&lt;DIV&gt;NOTE: 16945246 observations added.&lt;/DIV&gt;
&lt;DIV&gt;NOTE: The data set LIB_SQL.TAB1 has . observations and 4 variables.&lt;/DIV&gt;
&lt;DIV&gt;NOTE: PROCEDURE APPEND ha utilizzato (tempo totale di elaborazione):&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; real time&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;2:56:25.66&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; user cpu time&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;2:21.54&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; system cpu time&amp;nbsp; &amp;nbsp; &amp;nbsp;4:19.78&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; memory&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 593.34k&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; OS Memory&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;18784.00k&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; Timestamp&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;20/06/2023 05:34:11 p.&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; Step Count&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 243&amp;nbsp; Switch Count&amp;nbsp; 0&lt;/DIV&gt;</description>
      <pubDate>Wed, 21 Jun 2023 05:41:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/append-data-to-sql-data/m-p/881643#M348355</guid>
      <dc:creator>mariopellegrini</dc:creator>
      <dc:date>2023-06-21T05:41:03Z</dc:date>
    </item>
    <item>
      <title>Re: append data to sql data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/append-data-to-sql-data/m-p/881646#M348357</link>
      <description>&lt;P&gt;I do not know much about the environment you are working in. I assume that proc append just take a "few" observations and gives it to SQLServer who appends them. After doing so maybe the SQLServer starts re-creating&amp;nbsp; an index or so, waits for completion and after that accepts the next package.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I would try to get the data to be appended in the SQLServers database and let the SQLServer doing the append.&amp;nbsp; Something like this&amp;nbsp; :&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;proc upload data = backup.WXGC21K out = LIB_SQL.WXGC21K;run;

proc sql; 
	connect to  ODBC (dsn="MySQLServerConnectString" schema=dbo);
		execute (INSERT INTO TAB1  
					SELECT *
					FROM dbo.WXGC21K) by ODBC;
	disconnect from ODBC;
quit;

proc sql; 
	connect to ODBC (dsn="MySQLServerConnectString" schema=dbo);
		execute (Drop Table WXGC21K) by ODBC;
	disconnect from ODBC;
quit;;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;or if you have licenced SAS/Interface for Access to SQLServer you may try this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;proc upload data = backup.WXGC21K out = LIB_SQL.WXGC21K;run;

proc sql; 
	connect to  sqlsvr (user="Domain\UserID" password="MyPassword" datasrc="MySQLServerConnectString" schema=dbo);;
		execute (INSERT INTO TAB1  
					SELECT *
					FROM WXGC21K) by sqlsvr;
	disconnect from sqlsvr;
quit;

proc sql; 
	connect to sqlsvr (user="Domain\UserID" password="MyPassword" datasrc="MySQLServerConnectString" schema=dbo);
		execute (Drop Table WXGC21K) by sqlsvr;
	disconnect from sqlsvr;
quit;;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 21 Jun 2023 06:33:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/append-data-to-sql-data/m-p/881646#M348357</guid>
      <dc:creator>HenryKobus</dc:creator>
      <dc:date>2023-06-21T06:33:09Z</dc:date>
    </item>
    <item>
      <title>Re: append data to sql data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/append-data-to-sql-data/m-p/881656#M348362</link>
      <description>&lt;P&gt;Thank you. But I can't connect from proc sql.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;LIBNAME EDWHDSST SQLSVR Datasrc=EDWHDSST SCHEMA=DBO AUTHDOMAIN="SQLSRVAuth" ;&lt;/P&gt;
&lt;P&gt;NOTE: Libref EDWHDSST was successfully assigned as follows: &lt;BR /&gt;Engine: SQLSVR &lt;BR /&gt;Physical Name: EDWHDSST&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But this proc sql:&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;proc sql; &lt;BR /&gt;connect to SQLSVR as mydb (Datasrc="EDWHDSST" SCHEMA="DBO" AUTHDOMAIN="SQLSRVAuth" );&lt;BR /&gt;execute (SELECT * FROM TABSQL) by sqlsvr;&lt;BR /&gt;disconnect from sqlsvr;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;returns the following error:&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;27 proc sql;&lt;BR /&gt;28 connect to SQLSVR as mydb (Datasrc="EDWHDSST" SCHEMA="DBO" AUTHDOMAIN="SQLSRVAuth" );&lt;BR /&gt;NOTE: Credential obtained from SAS metadata server.&lt;BR /&gt;&lt;FONT color="#FF0000"&gt;ERROR: Invalid option name SCHEMA.&lt;/FONT&gt;&lt;BR /&gt;NOTE: PROC SQL set option NOEXEC and will continue to check the syntax of statements.&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;or using username and password:&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;proc sql; &lt;BR /&gt;connect to SQLSVR as mydb (Datasrc="DBO" user=user password=xxxx);&lt;BR /&gt;execute (SELECT * FROM TABSQL) by sqlsvr;&lt;BR /&gt;disconnect from sqlsvr;&lt;BR /&gt;quit;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#FF0000"&gt;ERROR: CLI error trying to establish connection: [Microsoft][ODBC Driver Manager] Data source name not found and no default driver &lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF0000"&gt;specified&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 21 Jun 2023 08:25:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/append-data-to-sql-data/m-p/881656#M348362</guid>
      <dc:creator>mariopellegrini</dc:creator>
      <dc:date>2023-06-21T08:25:55Z</dc:date>
    </item>
    <item>
      <title>Re: append data to sql data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/append-data-to-sql-data/m-p/881657#M348363</link>
      <description>&lt;P&gt;The schema is needed in LIBNAME statement. For pass through the tablespace follows the FROM statement and then a period + table name:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;proc sql;
connect to SQLSVR as mydb (Datasrc="EDWHDSST" AUTHDOMAIN="SQLSRVAuth" );
execute (SELECT * FROM dbo.TABSQL) by sqlsvr;
disconnect from sqlsvr;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 21 Jun 2023 08:19:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/append-data-to-sql-data/m-p/881657#M348363</guid>
      <dc:creator>HenryKobus</dc:creator>
      <dc:date>2023-06-21T08:19:15Z</dc:date>
    </item>
    <item>
      <title>Re: append data to sql data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/append-data-to-sql-data/m-p/881672#M348375</link>
      <description>&lt;P&gt;Okay. Thank you.&lt;/P&gt;
&lt;P&gt;What could I do instead of the proc upload?&lt;/P&gt;
&lt;P&gt;It seems that the possibility is not installed because I get the following error:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#FF0000"&gt;ERROR: Procedure UPLOAD not found.&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 21 Jun 2023 11:04:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/append-data-to-sql-data/m-p/881672#M348375</guid>
      <dc:creator>mariopellegrini</dc:creator>
      <dc:date>2023-06-21T11:04:59Z</dc:date>
    </item>
    <item>
      <title>Re: append data to sql data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/append-data-to-sql-data/m-p/881693#M348390</link>
      <description>&lt;P&gt;3 hours of real time vs. 7 minutes of CPU time points to bandwidth issues between the SAS and DB server.&lt;/P&gt;
&lt;P&gt;And 7 minutes vs. 15 seconds also means that the whole setup of the connection is inefficient.&lt;/P&gt;
&lt;P&gt;Get in touch with your SAS and DB admins, and study the documentation for your specific database connection (ODBC).&lt;/P&gt;
&lt;P&gt;Also see if you have ACCESS to SQL server licensed, it provides a more direct path (SAS - DB client - server instead of SAS - ODBC OS component - ODBC driver - server).&lt;/P&gt;</description>
      <pubDate>Wed, 21 Jun 2023 12:26:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/append-data-to-sql-data/m-p/881693#M348390</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2023-06-21T12:26:06Z</dc:date>
    </item>
    <item>
      <title>Re: append data to sql data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/append-data-to-sql-data/m-p/881695#M348391</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/3574"&gt;@mariopellegrini&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Good morning. A proc append in a SQL data library takes a very long time to append data. However, the same data on a basic sas library takes a few seconds. I report the 2 example logs.&lt;/P&gt;
&lt;P&gt;I'm asking for suggestions on which method is better to hang data on a Sql Server data library from sas:&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Better in what sense? If the criterion for "better" is the amount of time it takes, you have already found the answer.&lt;/P&gt;</description>
      <pubDate>Wed, 21 Jun 2023 12:19:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/append-data-to-sql-data/m-p/881695#M348391</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2023-06-21T12:19:24Z</dc:date>
    </item>
    <item>
      <title>Re: append data to sql data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/append-data-to-sql-data/m-p/881696#M348392</link>
      <description>Yes, but I need to bring data to SqlServer</description>
      <pubDate>Wed, 21 Jun 2023 12:26:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/append-data-to-sql-data/m-p/881696#M348392</guid>
      <dc:creator>mariopellegrini</dc:creator>
      <dc:date>2023-06-21T12:26:12Z</dc:date>
    </item>
    <item>
      <title>Re: append data to sql data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/append-data-to-sql-data/m-p/881698#M348394</link>
      <description>&lt;P&gt;Thank you.&lt;/P&gt;
&lt;P&gt;But assuming PROC UPLOAD worked, could it greatly improve data transfer times from sas to sql? ie i mean doing a dry proc upload of a table from sas to sql&lt;/P&gt;
&lt;P&gt;Another question: can there not be a "SQL Pass-Through" code that makes data transfer efficient?&lt;/P&gt;</description>
      <pubDate>Wed, 21 Jun 2023 12:47:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/append-data-to-sql-data/m-p/881698#M348394</guid>
      <dc:creator>mariopellegrini</dc:creator>
      <dc:date>2023-06-21T12:47:36Z</dc:date>
    </item>
    <item>
      <title>Re: append data to sql data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/append-data-to-sql-data/m-p/881700#M348396</link>
      <description>&lt;P&gt;PROC UPLOAD is part of SAS/CONNECT, which is used to communicate between two SAS processes. It is not used to connect to a database server.&lt;/P&gt;</description>
      <pubDate>Wed, 21 Jun 2023 12:43:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/append-data-to-sql-data/m-p/881700#M348396</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2023-06-21T12:43:19Z</dc:date>
    </item>
    <item>
      <title>Re: append data to sql data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/append-data-to-sql-data/m-p/881704#M348399</link>
      <description>&lt;P&gt;You may use a datastep or proc datasets / proc copy instead:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;data LIB_SQL.WXGC21K;
    set backup.WXGC21K ;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 21 Jun 2023 12:51:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/append-data-to-sql-data/m-p/881704#M348399</guid>
      <dc:creator>HenryKobus</dc:creator>
      <dc:date>2023-06-21T12:51:11Z</dc:date>
    </item>
    <item>
      <title>Re: append data to sql data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/append-data-to-sql-data/m-p/881810#M348440</link>
      <description>&lt;P&gt;In my experience, when appending SAS data to SQL Server tables you need to experiment with the INSERTBUFF data connection option. Changing this option can make a huge difference in table load times as the default value is not optimal. Try something like this, then experiment by increasing or reducing the value to see the impact:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;LIBNAME EDWHDSST SQLSVR Datasrc=EDWHDSST SCHEMA=DBO AUTHDOMAIN="SQLSRVAuth"  insertbuff = 10000;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Also to connect to SQL Server in PROC SQL you can use your LIBNAME:&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
  connect using EDWHDSST;
  create table MyTable as
  select * from connection to EDWHDSST
  (SELECT * FROM TABSQL) ;
  disconnect from EDWHDSST;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 22 Jun 2023 02:42:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/append-data-to-sql-data/m-p/881810#M348440</guid>
      <dc:creator>SASKiwi</dc:creator>
      <dc:date>2023-06-22T02:42:04Z</dc:date>
    </item>
    <item>
      <title>Re: append data to sql data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/append-data-to-sql-data/m-p/881850#M348452</link>
      <description>&lt;P&gt;Thank you very much! Thanks to this option the elaboration went to 3'39"!&lt;/P&gt;
&lt;P&gt;Is 10,000 usually what works best? Do you still advise me to try other values? Changing by how much?&lt;/P&gt;</description>
      <pubDate>Thu, 22 Jun 2023 08:05:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/append-data-to-sql-data/m-p/881850#M348452</guid>
      <dc:creator>mariopellegrini</dc:creator>
      <dc:date>2023-06-22T08:05:24Z</dc:date>
    </item>
    <item>
      <title>Re: append data to sql data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/append-data-to-sql-data/m-p/882020#M348489</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/3574"&gt;@mariopellegrini&lt;/a&gt;&amp;nbsp;- I don't think there is an ideal number for everyone. I usually try a few different values, like 1,000, 2,000, 5,000, 10,000, 15,000, 20,000 to see which gives the best performance. We currently use 10,000 for most of our loads and that works well. There is no point using a larger number than the number of rows you are appending though.&lt;/P&gt;</description>
      <pubDate>Thu, 22 Jun 2023 20:03:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/append-data-to-sql-data/m-p/882020#M348489</guid>
      <dc:creator>SASKiwi</dc:creator>
      <dc:date>2023-06-22T20:03:42Z</dc:date>
    </item>
  </channel>
</rss>

