<?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: Run teradata code from file and save as a  SAS dataset in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Run-teradata-code-from-file-and-save-as-a-SAS-dataset/m-p/560810#M156904</link>
    <description>&lt;P&gt;You can use pass through SQL code in SAS.&amp;nbsp; So assuming you have already made the libref MYLIB the basic syntax is to either pull the results of a query.&amp;nbsp; Or execute a statement.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
connection using mylib ;
create table work.test as select * from connection to mylib
( .... teradata select statement goes here ....)
;
execute 
( .... teradata statement goes here ....)
by mylib;
quit;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Wed, 22 May 2019 12:42:57 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2019-05-22T12:42:57Z</dc:date>
    <item>
      <title>Run teradata code from file and save as a  SAS dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Run-teradata-code-from-file-and-save-as-a-SAS-dataset/m-p/560801#M156901</link>
      <description>&lt;P&gt;In my organization some of the teams are working on Teradata while some are working on SAS depending on client requirement. I work on SAS but sometimes we need to replicate processes which are setup in Teradata(by other teams) to SAS.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Initially I thought that I could simply take the Teradata code and paste it in a proc sql step and it would work. However, a lot of functions which work in Teradata are not compatible with proc sql. So usually I replicate those steps in SAS by rewriting the code. This takes a lot of time.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I was wondering if there is a method by which I can directly call a Teradata code (saved in an SQL file) from SAS such that it runs in Teradata and the results get exported as a SAS dataset. This would eliminate the need to replicate the SQL codes in SAS.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I already have a code setup through which I connect to the teradata server and then i simply use the tables present there in SAS. It looks something like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;libname mylib teradata user=testuser password=testpass;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;However, I am not able to figure out how I can directly call a SQL code file from SAS such that it runs in Teradata. What I am looking for would involve these steps:&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;Save the Teradata code in an SQL file&lt;/LI&gt;&lt;LI&gt;Call the file from SAS such that it runs in Teradata&lt;/LI&gt;&lt;LI&gt;Import the code output to a SAS dataset&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;It feels that the step three is not directly possible so thought maybe I could do it in two steps - export the Teradata outputs to excel and then import the excel to SAS using proc import. I looked on the internet and found some functions like bteq export etc. but I am not able to put everything together.&lt;/P&gt;</description>
      <pubDate>Wed, 22 May 2019 12:27:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Run-teradata-code-from-file-and-save-as-a-SAS-dataset/m-p/560801#M156901</guid>
      <dc:creator>lakshayvohra</dc:creator>
      <dc:date>2019-05-22T12:27:33Z</dc:date>
    </item>
    <item>
      <title>Re: Run teradata code from file and save as a  SAS dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Run-teradata-code-from-file-and-save-as-a-SAS-dataset/m-p/560810#M156904</link>
      <description>&lt;P&gt;You can use pass through SQL code in SAS.&amp;nbsp; So assuming you have already made the libref MYLIB the basic syntax is to either pull the results of a query.&amp;nbsp; Or execute a statement.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
connection using mylib ;
create table work.test as select * from connection to mylib
( .... teradata select statement goes here ....)
;
execute 
( .... teradata statement goes here ....)
by mylib;
quit;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 22 May 2019 12:42:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Run-teradata-code-from-file-and-save-as-a-SAS-dataset/m-p/560810#M156904</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-05-22T12:42:57Z</dc:date>
    </item>
    <item>
      <title>Re: Run teradata code from file and save as a  SAS dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Run-teradata-code-from-file-and-save-as-a-SAS-dataset/m-p/560821#M156907</link>
      <description>&lt;P&gt;If you really want to call a seperate program, try %include within the SQL pass through block as shown by&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom&lt;/a&gt;. (untested)&lt;/P&gt;
&lt;P&gt;IN the long, I don't think it's good practice to separate those elements since you can't see in your SAS program what the Teradata SQL returns.&lt;/P&gt;</description>
      <pubDate>Wed, 22 May 2019 13:10:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Run-teradata-code-from-file-and-save-as-a-SAS-dataset/m-p/560821#M156907</guid>
      <dc:creator>LinusH</dc:creator>
      <dc:date>2019-05-22T13:10:09Z</dc:date>
    </item>
  </channel>
</rss>

