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

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

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.

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
  • 4 replies
  • 5074 views
  • 0 likes
  • 3 in conversation