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
PROC Star

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
PROC Star

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.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

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

View all other training opportunities.

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