<?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 Export SAS Table to SQL Server: Variable type Error in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Export-SAS-Table-to-SQL-Server-Variable-type-Error/m-p/227573#M54194</link>
    <description>&lt;P&gt;I can successfully export a table to a sql server database using the following code:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;LIBNAME SQL ODBC DSN="sql server" user=SAS_Connect pw=SASPass1;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc sql;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; drop table sql.baseball;&lt;BR /&gt;proc sql;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; create table sql.baseball as&lt;BR /&gt; select *&lt;BR /&gt;&amp;nbsp; &amp;nbsp; from sashelp.baseball&lt;BR /&gt;;quit;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This works fine for the example data but I am running into issues when I try to export larger tables (280 variables, 80,000 rows). I am receiving this error:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;ERROR: CLI execute error: [Microsoft][ODBC SQL Server Driver][SQL Server] Arithmetic overflow error for type smallint, value = 33841.000000. : [Microsoft][ODBC SQL Server Driver][SQL Server]The statement has been terminated.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am assuming that this is because when assigning sql server datatypes, the first observation&amp;nbsp;establishes which type&amp;nbsp;the algorithm thinks is best and then an error will occur if subsequent observations do not match that data type e.g. exceed allowable values. Is there a way that I can automatically set all numeric SAS variables to a type of "big int"? I would prefer to not have to specify the data type for all 280 variables. I have seen the "dtype" option for use with SAS/Access but I have only seen it applied to importing data. Please note that I have about zero experience working with sql server. I would simply like to export a large SAS table with many different variables similar to the example above. Any help or advice is much appreciated.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best,&lt;/P&gt;
&lt;P&gt;Daniel&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 28 Sep 2015 19:52:57 GMT</pubDate>
    <dc:creator>ddemilla</dc:creator>
    <dc:date>2015-09-28T19:52:57Z</dc:date>
    <item>
      <title>Export SAS Table to SQL Server: Variable type Error</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Export-SAS-Table-to-SQL-Server-Variable-type-Error/m-p/227573#M54194</link>
      <description>&lt;P&gt;I can successfully export a table to a sql server database using the following code:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;LIBNAME SQL ODBC DSN="sql server" user=SAS_Connect pw=SASPass1;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc sql;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; drop table sql.baseball;&lt;BR /&gt;proc sql;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; create table sql.baseball as&lt;BR /&gt; select *&lt;BR /&gt;&amp;nbsp; &amp;nbsp; from sashelp.baseball&lt;BR /&gt;;quit;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This works fine for the example data but I am running into issues when I try to export larger tables (280 variables, 80,000 rows). I am receiving this error:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;ERROR: CLI execute error: [Microsoft][ODBC SQL Server Driver][SQL Server] Arithmetic overflow error for type smallint, value = 33841.000000. : [Microsoft][ODBC SQL Server Driver][SQL Server]The statement has been terminated.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am assuming that this is because when assigning sql server datatypes, the first observation&amp;nbsp;establishes which type&amp;nbsp;the algorithm thinks is best and then an error will occur if subsequent observations do not match that data type e.g. exceed allowable values. Is there a way that I can automatically set all numeric SAS variables to a type of "big int"? I would prefer to not have to specify the data type for all 280 variables. I have seen the "dtype" option for use with SAS/Access but I have only seen it applied to importing data. Please note that I have about zero experience working with sql server. I would simply like to export a large SAS table with many different variables similar to the example above. Any help or advice is much appreciated.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best,&lt;/P&gt;
&lt;P&gt;Daniel&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2015 19:52:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Export-SAS-Table-to-SQL-Server-Variable-type-Error/m-p/227573#M54194</guid>
      <dc:creator>ddemilla</dc:creator>
      <dc:date>2015-09-28T19:52:57Z</dc:date>
    </item>
    <item>
      <title>Re: Export SAS Table to SQL Server: Variable type Error</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Export-SAS-Table-to-SQL-Server-Variable-type-Error/m-p/227582#M54196</link>
      <description>&lt;P&gt;Here's a link to the default data types that SAS defines:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A href="http://support.sas.com/documentation/cdl/en/acreldb/68028/HTML/default/viewer.htm#n0h4i25zq3t58en1lgr8jjx1rads.htm" target="_blank"&gt;http://support.sas.com/documentation/cdl/en/acreldb/68028/HTML/default/viewer.htm#n0h4i25zq3t58en1lgr8jjx1rads.htm&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I suggest you change the SAS format on the numeric variable giving the problem to having some decimal places (eg 8.2). That should switch the data type to NUMERIC.&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2015 21:34:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Export-SAS-Table-to-SQL-Server-Variable-type-Error/m-p/227582#M54196</guid>
      <dc:creator>SASKiwi</dc:creator>
      <dc:date>2015-09-28T21:34:59Z</dc:date>
    </item>
  </channel>
</rss>

