Reputation: 21
I am having an issue when loading SAS dates into Teradata. The date format in SAS was '01Jan2017'D, and after loading the dates in the teradata would show a string of number like 23050, but not in a date format. And I used put function before loading to change the format in SAS and also after loading I used cast date format function in Teradata, but neither of them worked.
Does anybody have the solution for this?
Thanks a lot for answering!
Upvotes: 1
Views: 1526
Reputation: 51611
Are you using SAS/Access to Teradata? If so it should automatically define the variable as a date in Teradata. Let's make a little table in SAS. Note that attaching a valid SAS date format is critical for SAS to understand that your variable has date values.
data have ;
mydate = '01JAN2017'd;
format mydate date9. ;
run;
Now let's upload it to a new teradata table.
libname td teradata ..... ;
data td.mytable ;
set have;
run;
Now let's read it back and see what is in it.
proc print data=td.mytable;
run;
Now if you have already loaded a lot of data into Teradata and the values look like the integer number of days since 1/1/1960, which is how SAS stores dates internally, then it is an easy calculation in Teradata to convert that to a date. Just add it back to date '1960-01-01'. Try running this query on your TD server.
select DATE '2017-01-01' date1, date '1960-01-01' + 20820 date2
Both DATE1 and DATE2 should be the same.
Upvotes: 1