<?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 How do I reference an Imported file in a PROC SQL WHERE statement? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-reference-an-Imported-file-in-a-PROC-SQL-WHERE/m-p/281559#M57122</link>
    <description>&lt;P&gt;If I use the PROC IMPORT statement to import an Excel file, how do I use that file in the WHERE statement in PROC SQL?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For example, I imported an Excel file that has three columns (Year, Product Number, Customer ID).&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Then, in my PROC SQL WHERE statement, I want my criteria to only be on the&amp;nbsp;Product Number(s) that are in&amp;nbsp;my imported file.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I can import the file; however, I am having trouble&amp;nbsp;running the PROC SQL statement for only the Product Number(s) in the import file.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you.&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 30 Jun 2016 20:33:20 GMT</pubDate>
    <dc:creator>BBLOCKOFETT</dc:creator>
    <dc:date>2016-06-30T20:33:20Z</dc:date>
    <item>
      <title>How do I reference an Imported file in a PROC SQL WHERE statement?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-reference-an-Imported-file-in-a-PROC-SQL-WHERE/m-p/281559#M57122</link>
      <description>&lt;P&gt;If I use the PROC IMPORT statement to import an Excel file, how do I use that file in the WHERE statement in PROC SQL?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For example, I imported an Excel file that has three columns (Year, Product Number, Customer ID).&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Then, in my PROC SQL WHERE statement, I want my criteria to only be on the&amp;nbsp;Product Number(s) that are in&amp;nbsp;my imported file.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I can import the file; however, I am having trouble&amp;nbsp;running the PROC SQL statement for only the Product Number(s) in the import file.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 30 Jun 2016 20:33:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-reference-an-Imported-file-in-a-PROC-SQL-WHERE/m-p/281559#M57122</guid>
      <dc:creator>BBLOCKOFETT</dc:creator>
      <dc:date>2016-06-30T20:33:20Z</dc:date>
    </item>
    <item>
      <title>Re: How do I reference an Imported file in a PROC SQL WHERE statement?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-reference-an-Imported-file-in-a-PROC-SQL-WHERE/m-p/281565#M57124</link>
      <description>&lt;P&gt;When you import the file, you saved the dataset in a location, where you referenced it in the OUT= statement. You can use that name in the rest of your code.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;OUT=&lt;FONT color="#008000"&gt;&lt;STRONG&gt;dataset_name&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;You can reference this in your SQL query&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
create table want as
select *
from table1
where product_number in (select product_number from &lt;STRONG&gt;&lt;FONT color="#008000"&gt;dataset_name&lt;/FONT&gt;)&lt;/STRONG&gt;;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 30 Jun 2016 21:11:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-reference-an-Imported-file-in-a-PROC-SQL-WHERE/m-p/281565#M57124</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-06-30T21:11:34Z</dc:date>
    </item>
    <item>
      <title>Re: How do I reference an Imported file in a PROC SQL WHERE statement?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-reference-an-Imported-file-in-a-PROC-SQL-WHERE/m-p/281726#M57164</link>
      <description>&lt;P&gt;Thank you, Reeza; however, I am still receiving some errors.&amp;nbsp; After the PROC IMPORT statement, do I need to specify the column names in order for the PROC SQL statement to recognize what I am referencing?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;After I IMPORT the Excel file, I am then connecting to a DB2 table, is there a join statement that I need to make?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The error I am receiving is:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;ERROR: CLI describe error: [IBM][CLI Driver][DB2] SQL0204N "ZCLMSAS.PAYMENTS1" is an undefined&lt;/P&gt;&lt;P&gt;name. SQLSTATE=42704&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;STRONG&gt;PROC&lt;/STRONG&gt;&lt;/FONT&gt; &lt;STRONG&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;SQL&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;CONNECT&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;TO&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt; odbc &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;as&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt; DB2; &lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;CREATE&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;TABLE&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt; AllData &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;AS&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;SELECT&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt; * &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;FROM&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt; CONNECTION TO DB2&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;(&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;SELECT&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;DISTINCT&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;DB2TABLE.CUSTOMER.PRODUCT_NUMBER,&lt;/P&gt;&lt;P&gt;DB2TABLE.CUSTOMER.YEAR,&lt;/P&gt;&lt;P&gt;DB2TABLE.CUSTOMER.CUSTOMER_ID&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;FROM&lt;/P&gt;&lt;P&gt;DB2TABLE.CUSTOMER&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;WHERE&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt;PRODUCT_NUMBER &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;in&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt; (&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;SELECT &lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt;PRODUCT_NUMBER &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;FROM&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt; PAYMENTS1);&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;)&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;DISCONNECT&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;FROM&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt; DB2;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;STRONG&gt;QUIT&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/FONT&gt;&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;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 01 Jul 2016 13:52:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-reference-an-Imported-file-in-a-PROC-SQL-WHERE/m-p/281726#M57164</guid>
      <dc:creator>BBLOCKOFETT</dc:creator>
      <dc:date>2016-07-01T13:52:51Z</dc:date>
    </item>
    <item>
      <title>Re: How do I reference an Imported file in a PROC SQL WHERE statement?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-reference-an-Imported-file-in-a-PROC-SQL-WHERE/m-p/281811#M57182</link>
      <description>????&lt;BR /&gt;What happened to the imported data from Excel? &lt;BR /&gt;The error you are receiving seems you be from DB2 do contact your dba to figure that one out.</description>
      <pubDate>Fri, 01 Jul 2016 22:14:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-reference-an-Imported-file-in-a-PROC-SQL-WHERE/m-p/281811#M57182</guid>
      <dc:creator>LinusH</dc:creator>
      <dc:date>2016-07-01T22:14:47Z</dc:date>
    </item>
    <item>
      <title>Re: How do I reference an Imported file in a PROC SQL WHERE statement?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-reference-an-Imported-file-in-a-PROC-SQL-WHERE/m-p/281812#M57183</link>
      <description>&lt;P&gt;First, as mentioned your error isn't from the import procedure but attempting to access your server.&lt;/P&gt;
&lt;P&gt;Second, you can't use a SAS table in a pass through query, which is what you're attempting to do. If you create a libname to your DB and then use a standard proc sql you can use the method suggested previously.&lt;/P&gt;</description>
      <pubDate>Fri, 01 Jul 2016 22:42:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-reference-an-Imported-file-in-a-PROC-SQL-WHERE/m-p/281812#M57183</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-07-01T22:42:45Z</dc:date>
    </item>
    <item>
      <title>Re: How do I reference an Imported file in a PROC SQL WHERE statement?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-reference-an-Imported-file-in-a-PROC-SQL-WHERE/m-p/282230#M57330</link>
      <description>&lt;P&gt;Thank you, Reeza.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;As you suggested, I added my LIBNAME statment at the beginning and was able to run my query with the coding you suggested.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Why are SAS tables unable to be referenced in a pass through query?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you.&lt;/P&gt;</description>
      <pubDate>Tue, 05 Jul 2016 17:50:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-reference-an-Imported-file-in-a-PROC-SQL-WHERE/m-p/282230#M57330</guid>
      <dc:creator>BBLOCKOFETT</dc:creator>
      <dc:date>2016-07-05T17:50:11Z</dc:date>
    </item>
    <item>
      <title>Re: How do I reference an Imported file in a PROC SQL WHERE statement?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-reference-an-Imported-file-in-a-PROC-SQL-WHERE/m-p/282286#M57346</link>
      <description>&lt;P&gt;Because pass through literally takes the code and passes it to server to process the query. The server doesn't have the SAS dataset.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It's also why the code is native to the SQL environment, ie MS SQL or Oracle SQL, not SAS SQL.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 05 Jul 2016 20:41:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-reference-an-Imported-file-in-a-PROC-SQL-WHERE/m-p/282286#M57346</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-07-05T20:41:07Z</dc:date>
    </item>
    <item>
      <title>Re: How do I reference an Imported file in a PROC SQL WHERE statement?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-reference-an-Imported-file-in-a-PROC-SQL-WHERE/m-p/282504#M57421</link>
      <description>Thank you for all the insight!!</description>
      <pubDate>Wed, 06 Jul 2016 18:18:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-reference-an-Imported-file-in-a-PROC-SQL-WHERE/m-p/282504#M57421</guid>
      <dc:creator>BBLOCKOFETT</dc:creator>
      <dc:date>2016-07-06T18:18:55Z</dc:date>
    </item>
  </channel>
</rss>

