<?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: PROQ SQL - Left joining on a sas dataset to a table pulled from a teradata server in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/PROQ-SQL-Left-joining-on-a-sas-dataset-to-a-table-pulled-from-a/m-p/625972#M184570</link>
    <description>&lt;P&gt;Try next code&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;PROC SQL;
  CONNECT TO ODBC(DATAsrc='SERVER NAME')&lt;BR /&gt;    ??? 
  (
     CREATE TABLE PULL1 AS
       SELECT *
       FROM SERVER.TERA_TABLE B
       RIGHT JOIN SAS_TABLE A
    ON A.ID = B.ID
);
QUIT;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I never used ODBC nor Terradata, and I have the feeling that code miss something in the ??? line, assigning SERVER library&lt;/P&gt;</description>
    <pubDate>Wed, 19 Feb 2020 20:08:23 GMT</pubDate>
    <dc:creator>Shmuel</dc:creator>
    <dc:date>2020-02-19T20:08:23Z</dc:date>
    <item>
      <title>PROQ SQL - Left joining on a sas dataset to a table pulled from a teradata server</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROQ-SQL-Left-joining-on-a-sas-dataset-to-a-table-pulled-from-a/m-p/625964#M184563</link>
      <description>&lt;P&gt;Hello all,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'll try to explain this as best as possible. I have a SAS Dataset with just one column, that has a list of about 3 to 4 million unique IDs. On the teradata server, there is a table whose data I want to pull for all the IDs in the SAS dataset. The issue I am encountering is that when I use PROC SQL, it does not recognize or seem to know about the SAS Dataset, thus I can't do a left (or right) join on the pull.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I also can not do a pull on just the table from the teradata server as it is extremely large and the only condition I have to limit the pull are these IDs. Here is an edited sample of the program I am running in what I am trying to do, with the SAS Dataset named SAS_TABLE and the teradata table named TERA_TABLE:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;PROC SQL;
  CONNECT TO ODBC(DATAsrc='SERVER NAME');
  CREATE TABLE PULL1 AS
  SELECT *
  FROM CONNECTION TO ODBC
  (
SELECT  *

FROM SERVER.TERA_TABLE B

RIGHT JOIN SAS_TABLE A
  ON A.ID = B.ID
);

QUIT;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;I've tried it this way and also a left join version, but each time, I get an error stating the SAS_TABLE does not exist:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;ERROR: CLI prepare error: [Teradata][ODBC Teradata Driver][Teradata Database] Object 'SAS_TABLE' does not exist&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am assuming what the program is trying to do is find "SAS_TABLE" in the actual database, which is what is causing this. Any help on this would really be appreciated, thanks!&lt;/P&gt;</description>
      <pubDate>Wed, 19 Feb 2020 19:51:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROQ-SQL-Left-joining-on-a-sas-dataset-to-a-table-pulled-from-a/m-p/625964#M184563</guid>
      <dc:creator>Sas_Act_114</dc:creator>
      <dc:date>2020-02-19T19:51:36Z</dc:date>
    </item>
    <item>
      <title>Re: PROQ SQL - Left joining on a sas dataset to a table pulled from a teradata server</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROQ-SQL-Left-joining-on-a-sas-dataset-to-a-table-pulled-from-a/m-p/625967#M184566</link>
      <description>&lt;P&gt;i do not use TERA data, but it seems that you should do something like this:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;PROC SQL;
  CONNECT TO ODBC(DATAsrc='SERVER NAME');
  /*Create table from remote datasource*/
  CREATE TABLE PULL1 AS
  SELECT *
  FROM CONNECTION TO ODBC
  (
  SELECT  * FROM SERVER.TERA_TABLE B
  )
;
/*join remote data extraction with table in sas*/
CREATE TABLE JOIN1 AS
  SELECT *
  FROM
  PULL1 A
  RIGHT JOIN SAS_TABLE B
  ON A.ID = B.ID
;

QUIT;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 19 Feb 2020 20:00:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROQ-SQL-Left-joining-on-a-sas-dataset-to-a-table-pulled-from-a/m-p/625967#M184566</guid>
      <dc:creator>utrocketeng</dc:creator>
      <dc:date>2020-02-19T20:00:56Z</dc:date>
    </item>
    <item>
      <title>Re: PROQ SQL - Left joining on a sas dataset to a table pulled from a teradata server</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROQ-SQL-Left-joining-on-a-sas-dataset-to-a-table-pulled-from-a/m-p/625971#M184569</link>
      <description>&lt;P&gt;The issue with this, is I can't just do a pull on the table from the Teradata server. This table is massive, I'm talking several 100 millions of rows of data and the pull times out due to how long it takes. Otherwise yes, your approach is exactly what I would be attempting&amp;nbsp;&lt;img id="smileyhappy" class="emoticon emoticon-smileyhappy" src="https://communities.sas.com/i/smilies/16x16_smiley-happy.png" alt="Smiley Happy" title="Smiley Happy" /&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 19 Feb 2020 20:04:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROQ-SQL-Left-joining-on-a-sas-dataset-to-a-table-pulled-from-a/m-p/625971#M184569</guid>
      <dc:creator>Sas_Act_114</dc:creator>
      <dc:date>2020-02-19T20:04:38Z</dc:date>
    </item>
    <item>
      <title>Re: PROQ SQL - Left joining on a sas dataset to a table pulled from a teradata server</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROQ-SQL-Left-joining-on-a-sas-dataset-to-a-table-pulled-from-a/m-p/625972#M184570</link>
      <description>&lt;P&gt;Try next code&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;PROC SQL;
  CONNECT TO ODBC(DATAsrc='SERVER NAME')&lt;BR /&gt;    ??? 
  (
     CREATE TABLE PULL1 AS
       SELECT *
       FROM SERVER.TERA_TABLE B
       RIGHT JOIN SAS_TABLE A
    ON A.ID = B.ID
);
QUIT;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I never used ODBC nor Terradata, and I have the feeling that code miss something in the ??? line, assigning SERVER library&lt;/P&gt;</description>
      <pubDate>Wed, 19 Feb 2020 20:08:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROQ-SQL-Left-joining-on-a-sas-dataset-to-a-table-pulled-from-a/m-p/625972#M184570</guid>
      <dc:creator>Shmuel</dc:creator>
      <dc:date>2020-02-19T20:08:23Z</dc:date>
    </item>
    <item>
      <title>Re: PROQ SQL - Left joining on a sas dataset to a table pulled from a teradata server</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROQ-SQL-Left-joining-on-a-sas-dataset-to-a-table-pulled-from-a/m-p/626048#M184585</link>
      <description>&lt;P&gt;Something along the line of below should work.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;libname mytera odbc &amp;lt;connection info&amp;gt; insertbuff=100000 readbuff=10000 dbcommit=0;

proc append base=mytera.tmp_tbl data=sas_table;
run;

proc sql;
  connect using mytera;
  create table pull1 as
    select *
      from connection to mytera
        (
          select  *
          from 
            server.tera_table a
            inner join
            server.tmp_tbl b
            on a.id=b.id
        );
  disconnect from mytera;
quit;

proc datasets lib=mytera nolist nowarn;
  delete tmp_tbl;
  run;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If you just want to pick rows with matching ID's from the big Teradata table then an inner join should do (and also perform better).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you also want all non-matching ID's from your SAS table in the final table on the SAS side and you expect quite a few ID's not to match then I'd add these ID's later on in a SAS data step. If you go for a left join then you will create rows on the Teradata side with all variables missing (except the ID) which you then have to load over the network into SAS.&lt;/P&gt;</description>
      <pubDate>Thu, 20 Feb 2020 04:28:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROQ-SQL-Left-joining-on-a-sas-dataset-to-a-table-pulled-from-a/m-p/626048#M184585</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2020-02-20T04:28:05Z</dc:date>
    </item>
    <item>
      <title>Re: PROQ SQL - Left joining on a sas dataset to a table pulled from a teradata server</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROQ-SQL-Left-joining-on-a-sas-dataset-to-a-table-pulled-from-a/m-p/626050#M184586</link>
      <description>&lt;P&gt;Does this work (assuming a numeric join key here) ?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
  set A end=LASTOBS;
  if _N_=1 then call execute("
    PROC SQL;
      CONNECT TO ODBC(DATAsrc='SERVER NAME');
      CREATE TABLE PULL1 AS
      SELECT *
      FROM CONNECTION TO ODBC
      ( SELECT  * FROM SERVER.TERA_TABLE WHERE ID IN(-999999 ");
  call execute(cats(',',ID));
  if LASTOBS then call execute('));quit;');
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Try with a few observations only, then when all is fine, run the whole list of values after redirecting the log using proc printto.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Some databases limit the number of values in a IN() list (Oracle's limit is 1000). in which case you need to insert OR operators between each reduced IN() clause.&lt;/P&gt;
&lt;P&gt;Teradata doesn't seem to have this limit, but its query size may be be limited to 1 MB. In that case you must send successive queries using subsets of your table A.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 20 Feb 2020 04:43:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROQ-SQL-Left-joining-on-a-sas-dataset-to-a-table-pulled-from-a/m-p/626050#M184586</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2020-02-20T04:43:24Z</dc:date>
    </item>
    <item>
      <title>Re: PROQ SQL - Left joining on a sas dataset to a table pulled from a teradata server</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROQ-SQL-Left-joining-on-a-sas-dataset-to-a-table-pulled-from-a/m-p/626053#M184587</link>
      <description>&lt;P&gt;Another option is to give DBMASTER a try. Documented &lt;A href="https://go.documentation.sas.com/?docsetId=acreldb&amp;amp;docsetTarget=n0jg0sozl17mjyn1woelrrr76266.htm&amp;amp;docsetVersion=9.4&amp;amp;locale=en" target="_self"&gt;here&lt;/A&gt;.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;libname mytera odbc &amp;lt;connection info&amp;gt; insertbuff=100000 readbuff=10000 dbcommit=0;

proc sql;
  create table pull1 as
    select a.*
    from 
      mytera.tera_table(dbmaster=yes) a
      inner join 
      sas_table b
      on a.id=b.id
    ;
quit;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 20 Feb 2020 05:26:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROQ-SQL-Left-joining-on-a-sas-dataset-to-a-table-pulled-from-a/m-p/626053#M184587</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2020-02-20T05:26:21Z</dc:date>
    </item>
    <item>
      <title>Re: PROQ SQL - Left joining on a sas dataset to a table pulled from a teradata server</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROQ-SQL-Left-joining-on-a-sas-dataset-to-a-table-pulled-from-a/m-p/626082#M184607</link>
      <description>&lt;P&gt;I&lt;EM&gt;t's unlikely that teradata can be wriitten to. Worth a try of course&lt;/EM&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 20 Feb 2020 09:42:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROQ-SQL-Left-joining-on-a-sas-dataset-to-a-table-pulled-from-a/m-p/626082#M184607</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2020-02-20T09:42:14Z</dc:date>
    </item>
    <item>
      <title>Re: PROQ SQL - Left joining on a sas dataset to a table pulled from a teradata server</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROQ-SQL-Left-joining-on-a-sas-dataset-to-a-table-pulled-from-a/m-p/626245#M184679</link>
      <description>&lt;P&gt;This is what I was looking for, thank you very much!&lt;/P&gt;</description>
      <pubDate>Thu, 20 Feb 2020 17:56:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROQ-SQL-Left-joining-on-a-sas-dataset-to-a-table-pulled-from-a/m-p/626245#M184679</guid>
      <dc:creator>Sas_Act_114</dc:creator>
      <dc:date>2020-02-20T17:56:23Z</dc:date>
    </item>
  </channel>
</rss>

