<?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: ERROR: WORK.table2 is an undefined name in SAS Enterprise Guide</title>
    <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/ERROR-WORK-table2-is-an-undefined-name/m-p/782938#M39928</link>
    <description>&lt;P&gt;So you created a SAS dataset and then asked DB2 to read from it?&amp;nbsp; That cannot work.&lt;/P&gt;
&lt;P&gt;If you want your DB2 code to access data you need to move the data into DB2.&lt;/P&gt;</description>
    <pubDate>Mon, 29 Nov 2021 15:51:37 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2021-11-29T15:51:37Z</dc:date>
    <item>
      <title>ERROR: WORK.table2 is an undefined name</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/ERROR-WORK-table2-is-an-undefined-name/m-p/782904#M39922</link>
      <description>Good morning everyone, I’m having a little trouble with what should be a simple PROC SQL CREATE TABLE in SAS EG.&lt;BR /&gt;&lt;BR /&gt;I imported an excel document into SAS EG and used a CREATE TABLE statement to make it into a table in SAS EG called TABLE2.&lt;BR /&gt;&lt;BR /&gt;I’m now trying to join it with a table in DB2, but am getting the error: work.table2 is an undefined name. SQLSTATE=42704. This is my code:&lt;BR /&gt;&lt;BR /&gt;———&lt;BR /&gt;&lt;BR /&gt;%loginmacro;&lt;BR /&gt;proc sql;&lt;BR /&gt;&lt;BR /&gt;CONNECT TO db2(login stuff);&lt;BR /&gt;&lt;BR /&gt;CREATE TABLE table3 as&lt;BR /&gt;SELECT * from connection to db2(&lt;BR /&gt;SELECT&lt;BR /&gt;A.*,&lt;BR /&gt;B.date&lt;BR /&gt;FROM&lt;BR /&gt;work.table2 a&lt;BR /&gt;INNER JOIN&lt;BR /&gt;schema.db2table b ON&lt;BR /&gt;a.ID = b.ID&lt;BR /&gt;) ;&lt;BR /&gt;&lt;BR /&gt;Disconnect from db2;&lt;BR /&gt;Quit;&lt;BR /&gt;&lt;BR /&gt;————&lt;BR /&gt;So table2 definitely exists because I did another program that simply was CREATE TABLE test as SELECT * from work.table2, just to make sure I wasn’t crazy, and it worked. But the above code gives me the undefined error.&lt;BR /&gt;&lt;BR /&gt;Is there something in the ordering I am doing wrong?&lt;BR /&gt;&lt;BR /&gt;Thank you!</description>
      <pubDate>Mon, 29 Nov 2021 13:25:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/ERROR-WORK-table2-is-an-undefined-name/m-p/782904#M39922</guid>
      <dc:creator>Boswser</dc:creator>
      <dc:date>2021-11-29T13:25:06Z</dc:date>
    </item>
    <item>
      <title>Re: ERROR: WORK.table2 is an undefined name</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/ERROR-WORK-table2-is-an-undefined-name/m-p/782932#M39927</link>
      <description>&lt;P&gt;Show us the complete (all of it, every single line) LOG of both programs. (Which one did you run first?)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please copy the LOG as text and paste it into the window that appears when you click on the &amp;lt;/&amp;gt; icon here in the SAS Communities.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Insert Log Icon in SAS Communities.png" style="width: 859px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/66171iFEC370B1DBF07B28/image-size/large?v=v2&amp;amp;px=999" role="button" title="Insert Log Icon in SAS Communities.png" alt="Insert Log Icon in SAS Communities.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 29 Nov 2021 15:40:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/ERROR-WORK-table2-is-an-undefined-name/m-p/782932#M39927</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2021-11-29T15:40:56Z</dc:date>
    </item>
    <item>
      <title>Re: ERROR: WORK.table2 is an undefined name</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/ERROR-WORK-table2-is-an-undefined-name/m-p/782938#M39928</link>
      <description>&lt;P&gt;So you created a SAS dataset and then asked DB2 to read from it?&amp;nbsp; That cannot work.&lt;/P&gt;
&lt;P&gt;If you want your DB2 code to access data you need to move the data into DB2.&lt;/P&gt;</description>
      <pubDate>Mon, 29 Nov 2021 15:51:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/ERROR-WORK-table2-is-an-undefined-name/m-p/782938#M39928</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-11-29T15:51:37Z</dc:date>
    </item>
    <item>
      <title>Re: ERROR: WORK.table2 is an undefined name</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/ERROR-WORK-table2-is-an-undefined-name/m-p/782945#M39929</link>
      <description>That makes sense. Unfortunately I am not able to upload data to DB2, and the DB2 table I am trying to match my imported data onto is many millions of rows, so pulling that DB2 table into SAS so it shows up under WORK will probably be too taxing for the system. I’ll have to find some other way. Thank you!</description>
      <pubDate>Mon, 29 Nov 2021 16:16:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/ERROR-WORK-table2-is-an-undefined-name/m-p/782945#M39929</guid>
      <dc:creator>Boswser</dc:creator>
      <dc:date>2021-11-29T16:16:40Z</dc:date>
    </item>
    <item>
      <title>Re: ERROR: WORK.table2 is an undefined name</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/ERROR-WORK-table2-is-an-undefined-name/m-p/782956#M39933</link>
      <description>&lt;P&gt;How many ids are in the WORK table?&amp;nbsp; If the list is small enough you might be able to use a macro variable to build your WHERE condition.&lt;/P&gt;
&lt;P&gt;Do you want all of the values from the DB2 table for the ID's in your WORK table?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql noprint;
select distinct ID into :list seprated by ',' from work.table2;
CONNECT TO db2(login stuff);
CREATE TABLE table3 as
  SELECT * from connection to db2
    (SELECT B.*
     FROM schema.db2table b
     where b.id in (&amp;amp;list)
    )
 ;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If the ID variable is character instead of numeric then change &lt;FONT face="courier new,courier"&gt;select distinct id into&lt;/FONT&gt;&amp;nbsp;to &lt;FONT face="courier new,courier"&gt;select distinct quote(trim(id),"'") into&lt;/FONT&gt; .&lt;/P&gt;
&lt;P&gt;If you just want the list of matching ids then change &lt;FONT face="courier new,courier"&gt;SELECT B.*&lt;/FONT&gt; to &lt;FONT face="courier new,courier"&gt;select distinct b.id&lt;/FONT&gt; .&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 29 Nov 2021 16:44:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/ERROR-WORK-table2-is-an-undefined-name/m-p/782956#M39933</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-11-29T16:44:16Z</dc:date>
    </item>
  </channel>
</rss>

