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

Loading SAS Date into SQL server. - Google Groups

I'm trying to load SAS date(format DATE9.,informat 8 int) into sql server database DATE column using ODBC connection.

          libname xxx ODBC DSN=xxxxxx bulkload=yes ;

          proc sql;
            INSERT into sqldb.tablename
                        select * from xy.sales;
          quit;

ERROR: Value 1 on the SELECT clause does not match the data type of the corresponding column listed after the INSERT table name.
 
my sas date format is MMDDYY10.


I appreciate any help on this.

Thanks.
1 ACCEPTED SOLUTION

Accepted Solutions
LinusH
Tourmaline | Level 20

Why do you start  a new post?

Not sure what you tried so far.

 

  1. I created a table in SQL server with date columns
  2. In SQL Server, inserted data into it, with datatime columns casted to date
  3. Queried the data in SQL Server, date columns looks fine
  4. Assigning libname in SAS. date columns appear with date9. format - values looks perfect.
  5. Created a transaction row in SAS, with SAS date values.
  6. Appended the data to the SQL Server table. New date values looks good.

If you have verified that all those steps, and you still have a problem - open a track to SAS tech support.

Data never sleeps

View solution in original post

4 REPLIES 4
LinusH
Tourmaline | Level 20

Are you sure that xy.sales has the exact column order as sqldb.tablename?

 

options sastrace=',,,d' sastraceloc=saslog;

might reveal any incnsistency between SAS and SQL Server.

Data never sleeps
chennupriya
Quartz | Level 8

please check this post 

 

https://communities.sas.com/t5/SAS-Procedures/Uploading-data-to-SQL-server-issue-with-Date-variable/...

 

I have the same problem as the dates coverting to 1960 when updating a table in sql server from sas 

 

pls help me 

SASKiwi
PROC Star

What format do you have on your SAS date column and what is the data type of the column you are trying to load the date into?

 

If you are loading an SQL Server datetime column then the SAS column must have a DATETIME format applied. 

LinusH
Tourmaline | Level 20

Why do you start  a new post?

Not sure what you tried so far.

 

  1. I created a table in SQL server with date columns
  2. In SQL Server, inserted data into it, with datatime columns casted to date
  3. Queried the data in SQL Server, date columns looks fine
  4. Assigning libname in SAS. date columns appear with date9. format - values looks perfect.
  5. Created a transaction row in SAS, with SAS date values.
  6. Appended the data to the SQL Server table. New date values looks good.

If you have verified that all those steps, and you still have a problem - open a track to SAS tech support.

Data never sleeps

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 4 replies
  • 5282 views
  • 0 likes
  • 3 in conversation