<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Generic script to pick datepart of datetime field and insert into tables in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Generic-script-to-pick-datepart-of-datetime-field-and-insert/m-p/189907#M35827</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Teradata is different as to other databases. I made the notes on that at: &lt;A _jive_internal="true" href="https://communities.sas.com/message/239871#239871"&gt;https://communities.sas.com/message/239871#239871&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The SAS/Access modules are doing the conversions based on the associated sas-formats&lt;/P&gt;&lt;P&gt;&lt;A href="http://support.sas.com//documentation/cdl/en/acreldb/67589/HTML/default/viewer.htm#p06jk0u30uhuj5n18fqw9sxr25lk.htm" title="http://support.sas.com//documentation/cdl/en/acreldb/67589/HTML/default/viewer.htm#p06jk0u30uhuj5n18fqw9sxr25lk.htm"&gt;SAS/ACCESS(R) 9.4 for Relational Databases: Reference, Sixth Edition&lt;/A&gt; (oracle) and &lt;A href="http://support.sas.com//documentation/cdl/en/acreldb/67589/HTML/default/viewer.htm#n0v7nh4ylrihtin1te8xl0q3dvzv.htm" title="http://support.sas.com//documentation/cdl/en/acreldb/67589/HTML/default/viewer.htm#n0v7nh4ylrihtin1te8xl0q3dvzv.htm"&gt;SAS/ACCESS(R) 9.4 for Relational Databases: Reference, Sixth Edition&lt;/A&gt; &lt;BR /&gt;You could use a proc copy from SAS with one side Oracle and at the other Teradata. That is the most easy way of thinking.&lt;/P&gt;&lt;P&gt;Using this with SAS dataset will work as the formats off all SAS variables are known when run.&lt;/P&gt;&lt;P&gt;There are two issues:&lt;/P&gt;&lt;P&gt;- going from Oracle to Teradata will have the effect of not using SAS tables and by that probably missing the SAS formats.&lt;/P&gt;&lt;P&gt;&amp;nbsp; That is why that direct copy can have issues.&lt;/P&gt;&lt;P&gt;- Storing tables in Teradata you must deal with that distributed approach there (nodes/amps). Choosing a "primary key" is MANAGING THAT DISTRIBUTION.&lt;/P&gt;&lt;P&gt;&amp;nbsp; That is why you should first define a table in Teradata (with primary key) and than load that using append with TERADATA OPTIONS.&lt;/P&gt;&lt;P&gt;When you understand this and is working fine you can improve that for a repeatable action.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;When you are having dates remember they are all technically different on all technically system although they are looking equal.&lt;/P&gt;&lt;P&gt;SAS is converting the dates for you using the mentioned approach. It is coming from several sources (skills Teradata ,&amp;nbsp; sas/access).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;There are exceptions on dates that cannot be converted.&lt;/P&gt;&lt;P&gt;- The Gregorian calendar started in 1580 or something like that. Dates before that are assumed to be invalid.&lt;/P&gt;&lt;P&gt;- Some business analysts introduced faked dates as some special case. When it is technical a string a DBMS accepted that. Neither SAS or Teradata will. 30-februari 32-may they are never valid. &lt;/P&gt;&lt;P&gt;- SAS is having the missing concept. Dates can be missing in SAS . This missing number does not exist in a DBMS. They are using an NULL concept (three value logic) for not being there.&lt;/P&gt;&lt;P&gt;This is something of doing dataquality. When there is rubbish in the old data than it is rubbish even when that was technically accepted.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 29 Nov 2014 08:56:44 GMT</pubDate>
    <dc:creator>jakarman</dc:creator>
    <dc:date>2014-11-29T08:56:44Z</dc:date>
    <item>
      <title>Generic script to pick datepart of datetime field and insert into tables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Generic-script-to-pick-datepart-of-datetime-field-and-insert/m-p/189904#M35824</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;BR /&gt;Ok, So Thank you SAS community and specially Reeza who helped me to built a generic script to populate 60 tables at one go.&lt;/P&gt;&lt;P&gt;Now, I want to insert datepart of a datetime field from oracle to teradata. So the logic would be:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%macro&lt;/P&gt;&lt;P&gt;Insert&amp;nbsp; into tera.&amp;amp;table_name (some columns, datepart(datetime_field)) select * from ora.&amp;amp;table_name;&lt;/P&gt;&lt;P&gt;%mend&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;and picking table from a dataset.&lt;/P&gt;&lt;P&gt;Now this should be parameterised.&lt;/P&gt;&lt;P&gt;Please help!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 28 Nov 2014 06:07:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Generic-script-to-pick-datepart-of-datetime-field-and-insert/m-p/189904#M35824</guid>
      <dc:creator>Hercules</dc:creator>
      <dc:date>2014-11-28T06:07:35Z</dc:date>
    </item>
    <item>
      <title>Re: Generic script to pick datepart of datetime field and insert into tables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Generic-script-to-pick-datepart-of-datetime-field-and-insert/m-p/189905#M35825</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Use the approaches for loading data to Teradata as documented by them.&amp;nbsp; You are on the paths of other approaches.&lt;/P&gt;&lt;P&gt;For dates. SAS is using numbers since 1 jan 1960 and Teradata is using them since 1 jan 1900. All conversions should be easily run when having set correct options.&lt;/P&gt;&lt;P&gt;It is based on the known formats associated with the SAS&amp;nbsp; variables.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The pitfalls:&lt;/P&gt;&lt;P&gt;- take attention to numeric precision (the famous 15/12 digits)&lt;/P&gt;&lt;P&gt;- with Teradata 14 the table names are limited to 30 whereas SAS is going to 32.&lt;/P&gt;&lt;P&gt;- As Teradata is designed for mass-processing is will not give always errors on every record processing.&lt;/P&gt;&lt;P&gt;&amp;nbsp; Sometimes duplicates and other erroneous records are placed in special datasets (adding 3 letters to the table) and everything is marked ok.&lt;/P&gt;&lt;P&gt;- There are mote datatypes in Teradata as in SAS (as usual). Conversion could make sense&lt;/P&gt;&lt;P&gt;&amp;nbsp; Do you do some cooperation with a Teradata DBA?&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 28 Nov 2014 11:08:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Generic-script-to-pick-datepart-of-datetime-field-and-insert/m-p/189905#M35825</guid>
      <dc:creator>jakarman</dc:creator>
      <dc:date>2014-11-28T11:08:30Z</dc:date>
    </item>
    <item>
      <title>Re: Generic script to pick datepart of datetime field and insert into tables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Generic-script-to-pick-datepart-of-datetime-field-and-insert/m-p/189906#M35826</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You didn't get me Jaap.&lt;/P&gt;&lt;P&gt;I have a structure made in teradata for a table.&lt;/P&gt;&lt;P&gt;For example, I have a table dummy_tera having a column start_date as date column.&lt;/P&gt;&lt;P&gt;Now I have another table dummy_ora having same structure as dummy_tera with data but only difference is that it is timestamp datatype.&lt;/P&gt;&lt;P&gt;Now if I apply datepart(start_date) and then insert it into Teradata table using&lt;/P&gt;&lt;P&gt;proc sql;&lt;/P&gt;&lt;P&gt;Insert into... Select * from...&lt;/P&gt;&lt;P&gt;THEN IT WORKS PERFECTLY FINE, otherwise it give an error that SAS VALUE CANNOT BE CONVERTED INTO TERADATA DATE.&lt;/P&gt;&lt;P&gt;Now I made a generic script which rather a macro which can load as many table as anyone want at a time which do not have date columns.&lt;/P&gt;&lt;P&gt;I want to optimize my script so that it can handle date columns as well. So that It can apply datepart automatically whenever it searches a date type field.&lt;/P&gt;&lt;P&gt;For that I need an idea.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 29 Nov 2014 05:07:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Generic-script-to-pick-datepart-of-datetime-field-and-insert/m-p/189906#M35826</guid>
      <dc:creator>Hercules</dc:creator>
      <dc:date>2014-11-29T05:07:59Z</dc:date>
    </item>
    <item>
      <title>Re: Generic script to pick datepart of datetime field and insert into tables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Generic-script-to-pick-datepart-of-datetime-field-and-insert/m-p/189907#M35827</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Teradata is different as to other databases. I made the notes on that at: &lt;A _jive_internal="true" href="https://communities.sas.com/message/239871#239871"&gt;https://communities.sas.com/message/239871#239871&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The SAS/Access modules are doing the conversions based on the associated sas-formats&lt;/P&gt;&lt;P&gt;&lt;A href="http://support.sas.com//documentation/cdl/en/acreldb/67589/HTML/default/viewer.htm#p06jk0u30uhuj5n18fqw9sxr25lk.htm" title="http://support.sas.com//documentation/cdl/en/acreldb/67589/HTML/default/viewer.htm#p06jk0u30uhuj5n18fqw9sxr25lk.htm"&gt;SAS/ACCESS(R) 9.4 for Relational Databases: Reference, Sixth Edition&lt;/A&gt; (oracle) and &lt;A href="http://support.sas.com//documentation/cdl/en/acreldb/67589/HTML/default/viewer.htm#n0v7nh4ylrihtin1te8xl0q3dvzv.htm" title="http://support.sas.com//documentation/cdl/en/acreldb/67589/HTML/default/viewer.htm#n0v7nh4ylrihtin1te8xl0q3dvzv.htm"&gt;SAS/ACCESS(R) 9.4 for Relational Databases: Reference, Sixth Edition&lt;/A&gt; &lt;BR /&gt;You could use a proc copy from SAS with one side Oracle and at the other Teradata. That is the most easy way of thinking.&lt;/P&gt;&lt;P&gt;Using this with SAS dataset will work as the formats off all SAS variables are known when run.&lt;/P&gt;&lt;P&gt;There are two issues:&lt;/P&gt;&lt;P&gt;- going from Oracle to Teradata will have the effect of not using SAS tables and by that probably missing the SAS formats.&lt;/P&gt;&lt;P&gt;&amp;nbsp; That is why that direct copy can have issues.&lt;/P&gt;&lt;P&gt;- Storing tables in Teradata you must deal with that distributed approach there (nodes/amps). Choosing a "primary key" is MANAGING THAT DISTRIBUTION.&lt;/P&gt;&lt;P&gt;&amp;nbsp; That is why you should first define a table in Teradata (with primary key) and than load that using append with TERADATA OPTIONS.&lt;/P&gt;&lt;P&gt;When you understand this and is working fine you can improve that for a repeatable action.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;When you are having dates remember they are all technically different on all technically system although they are looking equal.&lt;/P&gt;&lt;P&gt;SAS is converting the dates for you using the mentioned approach. It is coming from several sources (skills Teradata ,&amp;nbsp; sas/access).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;There are exceptions on dates that cannot be converted.&lt;/P&gt;&lt;P&gt;- The Gregorian calendar started in 1580 or something like that. Dates before that are assumed to be invalid.&lt;/P&gt;&lt;P&gt;- Some business analysts introduced faked dates as some special case. When it is technical a string a DBMS accepted that. Neither SAS or Teradata will. 30-februari 32-may they are never valid. &lt;/P&gt;&lt;P&gt;- SAS is having the missing concept. Dates can be missing in SAS . This missing number does not exist in a DBMS. They are using an NULL concept (three value logic) for not being there.&lt;/P&gt;&lt;P&gt;This is something of doing dataquality. When there is rubbish in the old data than it is rubbish even when that was technically accepted.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 29 Nov 2014 08:56:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Generic-script-to-pick-datepart-of-datetime-field-and-insert/m-p/189907#M35827</guid>
      <dc:creator>jakarman</dc:creator>
      <dc:date>2014-11-29T08:56:44Z</dc:date>
    </item>
    <item>
      <title>Re: Generic script to pick datepart of datetime field and insert into tables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Generic-script-to-pick-datepart-of-datetime-field-and-insert/m-p/189908#M35828</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;ACHIEVED!!!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have written a script which can insert into n number of tables of teradata, source as Oracle.&lt;/P&gt;&lt;P&gt;Also it will add audit columns, surrogate key and will pick datetime columns from oracle and insert into date columns of teradata table..&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;All can be done using only one script.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 07 Dec 2014 10:41:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Generic-script-to-pick-datepart-of-datetime-field-and-insert/m-p/189908#M35828</guid>
      <dc:creator>Hercules</dc:creator>
      <dc:date>2014-12-07T10:41:48Z</dc:date>
    </item>
  </channel>
</rss>

