BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
ddemilla
Fluorite | Level 6

I can successfully export a table to a sql server database using the following code:

 

LIBNAME SQL ODBC DSN="sql server" user=SAS_Connect pw=SASPass1; 

 

proc sql;
    drop table sql.baseball;
proc sql;
    create table sql.baseball as
select *
    from sashelp.baseball
;quit;

 

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:

 

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.

 

I am assuming that this is because when assigning sql server datatypes, the first observation establishes which type 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.

 

Best,

Daniel

 

1 ACCEPTED SOLUTION

Accepted Solutions
SASKiwi
Opal | Level 21

Here's a link to the default data types that SAS defines:

 

http://support.sas.com/documentation/cdl/en/acreldb/68028/HTML/default/viewer.htm#n0h4i25zq3t58en1lg...

 

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.

View solution in original post

1 REPLY 1
SASKiwi
Opal | Level 21

Here's a link to the default data types that SAS defines:

 

http://support.sas.com/documentation/cdl/en/acreldb/68028/HTML/default/viewer.htm#n0h4i25zq3t58en1lg...

 

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.

SAS INNOVATE 2024

Innovate_SAS_Blue.png

Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.

If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website. 

Register now!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

Find more tutorials on the SAS Users YouTube channel.

Get the $99 certification deal.jpg

 

 

Back in the Classroom!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 1 reply
  • 5664 views
  • 0 likes
  • 2 in conversation