06-30-2011 12:14 PM
Thank you very much, chang_y_chung. The link provides very helpful infomation. It turns out that we don't currently have license (Integration Technologies) to access SAS data files from outside SAS. But we do currently have license (SAS/Access) to access SQL Server from a SAS program. I now have an issue dealing with SQL Server datetime type field.
The column as SAS sees is (InvoiceDate is a datetime type defined in SQL Server):
InvoiceDate Num 8 DATETIME22.3 DATETIME22.3 InvoiceDate
The field in SAS data file is:
INVCDATE Num 8 MMDDYY10. INVOICE DATE (SAS)
But when I tried to insert the record into SQL Server from SAS data file, I got data type mismatch error or inserted incorrectly (showing 1960-01-01 xxxxxx). Does anybody have a solution to this?
Thanks in advance!
07-05-2011 02:29 AM
an example about inserting datetime into sql server :
%let nowdate = %sysfunc(today(),date7.);
%let nowtime = %sysfunc( time(),time5.);
insert into AAA.BBB (Current Date&time)
VALUES ("&nowdate &nowtime");
Don't forget if you're trying to write a datetime from a mmddyy10 format you have to give him hhmmss.
it's the trick in sas between a date format and a datetime.
why not write into your sql server this function : dhms(invcdate,0,0,0)