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
Here's a link to the default data types that SAS defines:
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.
Here's a link to the default data types that SAS defines:
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.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 16. Read more here about why you should contribute and what is in it for you!
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.
Select SAS Training centers are offering in-person courses. View upcoming courses for: