I have date values in my SQL Server database and am accessing them through ACCESS ODBC. Accessing them works fine but the dates come back as character values which I can't use. How do I get them into a format where I can use them for date math and date functions in a DATA or other PROC step?
CREATE TABLE mikey
SELECT NAME,DOB,Enrolled from SQLServer.EnrollmentTable;
I do a libdef to point the SQLServer library to my sqlserver database. It all works fine and the data comes back. The problem is that the DOB (date of birth) and enrolled (date of enrollment) come back as strings of format yyy-mm-dd 00:00:00
I do get data back but then can't work with these two variables as dates. The format seemed to be YMDDTTM24. but it doesn't find it. I am using SAS/PC 9.2.
I have tried several things, including the following, but nothing works...... Do you ever get dates from DB2 or SQL or Orable? I am using ACCESS for ODBC.
SELECT NAME,INPUT(DOB,date9.) as DOB,Enrolled from SQLServer.EnrollmentTable;
SELECT NAME,DOB INFORMAT=YMDDTTM24. ,Enrolled from SQLServer.EnrollmentTable;
I frequently get date data back from Oracle. In my case it comes back as a datetime value that I need to parse out into date and/or time variables in a datastep following the SQL step to turn the Oracle date value into a SAS date value.
You are fortunate. The SAS saleslady talked me into getting ACCESS for ODBC instead of ACCESS for SQL Server and now my dates come back as strings. I have spent all day trying to figure out how to use the darn things. I can't believe this is so difficult.
Obviously it won't be difficult once I get one stinking little example, but I can't find it.
My latest guess was to read in all the data, just accept the text. Then try to get it into Date variables with the following.... it doesn't work.
format DOBDate date7.;
DOBDate = input( dob , YMDDTTM24.);
ExDate = input( ExEnd , YMDDTTM24.);
format ExDate date7.;
ComboDate = input( ComboEnd , YMDDTTM24.);
format ComboDate date7.;