<?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: Snowflake Queries in SAS Enterprise Guide</title>
    <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Snowflake-Queries/m-p/987305#M46492</link>
    <description>&lt;P&gt;Below is my query. Please note that I have changed the names of fields/tables/schema/db, They are all made up names but the logic and layout is same. When I run it, it does not go past the %include statement. It keeps running.. there is no log after that. Hope it helps. Thank you!&lt;/P&gt;&lt;P&gt;------------------------- query --------------------------------------------------------------------&lt;/P&gt;&lt;DIV&gt;&lt;FONT size="3"&gt;%include "Snowflake_libname.sas"; (has libnames)&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="3"&gt;PROC SQL;&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="3"&gt;CONNECT USING SNOW AS SF;&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="3"&gt;CREATE&amp;nbsp; TABLE test AS&amp;nbsp;&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="3"&gt;select * from connection to SF&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="3"&gt;(select DISTINCT&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="3"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; b.cust_nbr&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="3"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;,b.cust_nm&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="3"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;,cast((a.PT_KEY) as varchar(20)) as PT_key&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="3"&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;,c.indvid&amp;nbsp;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="3"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;,c.first_name&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="3"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;,c.last_name&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="3"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;,c.clmnt_dob&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="3"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;,a.dx_code&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="3"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;,d.dx_desc&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="3"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;,a.px_cd&amp;nbsp;&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="3"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;,a.service_dt&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="3"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;,a.process_dt&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="3"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;,a.PD_DT&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="3"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;,e.location&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="3"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;,a.cov_paymt&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="3"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;,a.net_pd_paymt&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="3"&gt;from "db"."schema"."table1" a&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="3"&gt;join "db"."schema"."table2" as b&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="3"&gt;on a.PT_KEY = b.PT_KEY&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="3"&gt;join "db"."schema"."table3" c&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="3"&gt;on a.PT_KEY = c.PT_KEY&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="3"&gt;left join "db"."schema"."table4" d&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="3"&gt;on a.dx_cd = d.dx_cd&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="3"&gt;left join "db"."schema"."table5" e&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="3"&gt;on a.location_cd = e.location_cd&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="3"&gt;where&amp;nbsp;&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="3"&gt;&lt;SPAN&gt;indvid = 1234567&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="3"&gt;and&amp;nbsp; c.first_name='Jane'&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="3"&gt;and c.last_name='Doe'&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="3"&gt;&amp;nbsp;and a.service_dt&amp;nbsp; &amp;gt;= '2024-04-01');&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="3"&gt;quit;&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;</description>
    <pubDate>Tue, 05 May 2026 16:41:35 GMT</pubDate>
    <dc:creator>SASMom2</dc:creator>
    <dc:date>2026-05-05T16:41:35Z</dc:date>
    <item>
      <title>Snowflake Queries</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Snowflake-Queries/m-p/987121#M46482</link>
      <description>&lt;P&gt;I need some help figuring out if what I want to accomplish is possible. I pull base data from our system/databases in Snowflake using sql queries. The result tables are saved in Snowflake. Then I pull data (saved in Snowflake tables) into SAS EG by connecting to Snowflake through libnames. Then I analyze data in SAS EG and create a final report. For some of our reports there is a lot of back and forth between Snowflake cloud (Snowflake app, not in SAS EG) and SAS EG.&lt;/P&gt;&lt;P&gt;Is there anyway, I can create a procedure/macro (or something) in snowflake for each sql query that is in Snowflake cloud and call that in SAS EG? This way, I do not have to go back and forth between Snowflake and SAS EG.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you in advance!&lt;/P&gt;</description>
      <pubDate>Sun, 03 May 2026 03:15:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Snowflake-Queries/m-p/987121#M46482</guid>
      <dc:creator>SASMom2</dc:creator>
      <dc:date>2026-05-03T03:15:14Z</dc:date>
    </item>
    <item>
      <title>Re: Snowflake Queries</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Snowflake-Queries/m-p/987124#M46483</link>
      <description>&lt;P&gt;You can use SAS code to execute queries in Snowflake.&amp;nbsp; If you already have a LIBREF defined pointing to Snowflake database then that should be all you need.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can use PROC SQL to run queries.&amp;nbsp; First make the connection by using the CONNECT USING statement.&amp;nbsp; Then you can use&amp;nbsp; the EXECUTE statement to run a command that does not return any output. Or the FROM CONNECTION TO clause for one that does.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So let's assume you defined the libref SNOW pointing to Snowflake&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
connect using snow;
execute by snow (...some Snowflake command...);
create table want as 
select * from connection to snow
(... some Snowflake query ...)
;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;You can use the front end tool Enterprise Guide to create and run the SAS code.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 03 May 2026 19:11:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Snowflake-Queries/m-p/987124#M46483</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2026-05-03T19:11:58Z</dc:date>
    </item>
    <item>
      <title>Re: Snowflake Queries</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Snowflake-Queries/m-p/987126#M46484</link>
      <description>&lt;P&gt;Thank you so much for your reply. I feel like I am almost there but yet! Below is my code.&lt;/P&gt;&lt;P&gt;--------------------- Code -----------------------------&lt;/P&gt;&lt;DIV&gt;&lt;FONT face="arial,helvetica,sans-serif" size="4"&gt;proc sql;&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT face="arial,helvetica,sans-serif" size="4"&gt;connect using snow as sf;&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT face="arial,helvetica,sans-serif" size="4"&gt;execute by sf;&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT face="arial,helvetica,sans-serif" size="4"&gt;create table test as&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT face="arial,helvetica,sans-serif" size="4"&gt;select * from connection to sf&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT face="arial,helvetica,sans-serif" size="4"&gt;(select distinct&amp;nbsp;&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT face="arial,helvetica,sans-serif" size="4"&gt;&lt;SPAN&gt;b.cust_seg_nbr&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT face="arial,helvetica,sans-serif" size="4"&gt;&lt;SPAN&gt;,b.cust_seg_nm&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT face="arial,helvetica,sans-serif" size="4"&gt;from snowflake_db as b&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="4"&gt;&lt;FONT face="arial,helvetica,sans-serif"&gt;where b.cust_seg_nbr in ('91090334', '091090334', '0091090334', '00091090334')&lt;/FONT&gt;&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="4"&gt;&lt;FONT face="arial,helvetica,sans-serif"&gt;);&lt;/FONT&gt;&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT face="arial,helvetica,sans-serif" size="4"&gt;quit;&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT face="arial,helvetica,sans-serif" size="4"&gt;-----------------------------------------------------&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT face="arial,helvetica,sans-serif" size="4"&gt;The "snowflake_db" is the location of a table in a database in Snowflake.&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT face="arial,helvetica,sans-serif" size="4"&gt;I am getting below error when I run it. I do not know the reason I am getting it.&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT face="arial,helvetica,sans-serif" size="4"&gt;------------ below is the error I am getting -------------------------&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;_&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;P&gt;79&lt;BR /&gt;76&lt;BR /&gt;ERROR 79-322: Expecting a (.&lt;/P&gt;&lt;P&gt;ERROR 76-322: Syntax error, statement will be ignored.&lt;/P&gt;&lt;P&gt;---------------------------------------------------------------------&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you&lt;/P&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;</description>
      <pubDate>Mon, 04 May 2026 01:34:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Snowflake-Queries/m-p/987126#M46484</guid>
      <dc:creator>SASMom2</dc:creator>
      <dc:date>2026-05-04T01:34:33Z</dc:date>
    </item>
    <item>
      <title>Re: Snowflake Queries</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Snowflake-Queries/m-p/987127#M46485</link>
      <description>&lt;P&gt;Remove the partial EXECUTE statement, that is what is missing the ().&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It does not look like you are trying to execute anything so you don't need that statement.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Note that everything inside the () after the FROM CONNECTION TO xx clause has to be valid Snowflake SQL syntax.&lt;/P&gt;</description>
      <pubDate>Mon, 04 May 2026 02:15:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Snowflake-Queries/m-p/987127#M46485</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2026-05-04T02:15:13Z</dc:date>
    </item>
    <item>
      <title>Re: Snowflake Queries</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Snowflake-Queries/m-p/987129#M46486</link>
      <description>&lt;P&gt;That worked great! Thank you!&lt;/P&gt;&lt;P&gt;Now, I am going to try a bit complicated query. This query filters records using member first name, last name and date of birth under 'where' section in proc sql. In Snowflake names and date of birth are set as below on the top of the query&lt;/P&gt;&lt;P&gt;---------------------------------------------&lt;/P&gt;&lt;P&gt;SET fname = 'ABC';&lt;BR /&gt;SET lname = 'DEFG';&lt;BR /&gt;SET BMTH= '9999-12-31';&lt;/P&gt;&lt;P&gt;--------------------------------------------------------&lt;/P&gt;&lt;DIV&gt;where&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;SPAN&gt;first_name=$fname&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;and last_name=$lname&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;and DOB = $BMTH;&lt;/DIV&gt;&lt;DIV&gt;------------------------------------------------------------------------------------------&lt;/DIV&gt;&lt;DIV&gt;Where and how in SAS should I put the 'SET' statements?&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Thank you&lt;/DIV&gt;</description>
      <pubDate>Mon, 04 May 2026 03:12:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Snowflake-Queries/m-p/987129#M46486</guid>
      <dc:creator>SASMom2</dc:creator>
      <dc:date>2026-05-04T03:12:17Z</dc:date>
    </item>
    <item>
      <title>Re: Snowflake Queries</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Snowflake-Queries/m-p/987130#M46487</link>
      <description>&lt;P&gt;Why?&amp;nbsp; Are you trying to do code generation?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can use SAS's macro language to do code generation.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let fname = 'ABC';
%let lname = 'DEFG';
%let BMTH= '9999-12-31';
....
proc sql ;
....
where first_name=&amp;amp;fname
  and last_name=&amp;amp;lname
  and DOB = &amp;amp;BMTH
....&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 04 May 2026 04:25:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Snowflake-Queries/m-p/987130#M46487</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2026-05-04T04:25:21Z</dc:date>
    </item>
    <item>
      <title>Re: Snowflake Queries</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Snowflake-Queries/m-p/987169#M46488</link>
      <description>&lt;P&gt;Thank you for all your help! When I tried to run a Snowflake query that pull data from one table, it ran quickly but when I tried q query that pulls data from 5 tables in Snowflake, it kept running. Finally, I stopped it after 5 hours. When I run the same query directly in Snowflake, it runs in under a minute. So, I would definitely be using your method&amp;nbsp; for queries that use one table but not for queries that use multiple tables. I was hoping that it would work for complicated queries as it would save a lot of manually going back and forth between Snowflake and SAS.&lt;/P&gt;&lt;P&gt;Thank you!&lt;/P&gt;</description>
      <pubDate>Mon, 04 May 2026 17:03:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Snowflake-Queries/m-p/987169#M46488</guid>
      <dc:creator>SASMom2</dc:creator>
      <dc:date>2026-05-04T17:03:15Z</dc:date>
    </item>
    <item>
      <title>Re: Snowflake Queries</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Snowflake-Queries/m-p/987187#M46489</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/283628"&gt;@SASMom2&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Thank you for all your help! When I tried to run a Snowflake query that pull data from one table, it ran quickly but when I tried q query that pulls data from 5 tables in Snowflake, it kept running. Finally, I stopped it after 5 hours. When I run the same query directly in Snowflake, it runs in under a minute. So, I would definitely be using your method&amp;nbsp; for queries that use one table but not for queries that use multiple tables. I was hoping that it would work for complicated queries as it would save a lot of manually going back and forth between Snowflake and SAS.&lt;/P&gt;
&lt;P&gt;Thank you!&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Without an example I can only guess what you did.&amp;nbsp; But here are some possibilities:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You somehow asked SAS to execute the joins instead of giving the whole query to Snowflake to run.&amp;nbsp; If you ended up doing that then SAS would probably try to pull the whole table over and then join them which could take a very long time.&amp;nbsp; For example do NOT do something like this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;select * from work.mytable a left join snow.dbtable b 
  on a.id = b.id
;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Instead either upload the list SAS dataset into Snowflake then then perform the join completely in Snowflake.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The sizes of the result sets was vastly different between the two queries and so you are seeing how slow your connection to Snowflake is.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;There are options you can turn on to have SAS write the SQL it sends to Snowflake into the SAS log so you can see exactly what SAS ended up asking to be run.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://documentation.sas.com/doc/en/workbenchcdc/v_001/vwbacdata/n0sa0yux9sqf90n1ttzxhko2cit4.htm" target="_blank"&gt;https://documentation.sas.com/doc/en/workbenchcdc/v_001/vwbacdata/n0sa0yux9sqf90n1ttzxhko2cit4.htm&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can then try running that code in Snowflake and time how long it takes.&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>Mon, 04 May 2026 20:16:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Snowflake-Queries/m-p/987187#M46489</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2026-05-04T20:16:09Z</dc:date>
    </item>
    <item>
      <title>Re: Snowflake Queries</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Snowflake-Queries/m-p/987209#M46490</link>
      <description>&lt;P&gt;Please provide the query (and log) so we can help analyze it, ideally with using the options in the link from &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom&lt;/a&gt;.&lt;/P&gt;</description>
      <pubDate>Tue, 05 May 2026 13:08:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Snowflake-Queries/m-p/987209#M46490</guid>
      <dc:creator>LinusH</dc:creator>
      <dc:date>2026-05-05T13:08:50Z</dc:date>
    </item>
    <item>
      <title>Re: Snowflake Queries</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Snowflake-Queries/m-p/987217#M46491</link>
      <description>&lt;P&gt;I did exactly what you said not to do. Can you please clarify below.&lt;/P&gt;&lt;P&gt;"&lt;SPAN&gt;Instead either upload the list SAS dataset into Snowflake then then perform the join completely in Snowflake."&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;It is from your message.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Thank you&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 05 May 2026 15:27:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Snowflake-Queries/m-p/987217#M46491</guid>
      <dc:creator>SASMom2</dc:creator>
      <dc:date>2026-05-05T15:27:38Z</dc:date>
    </item>
    <item>
      <title>Re: Snowflake Queries</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Snowflake-Queries/m-p/987305#M46492</link>
      <description>&lt;P&gt;Below is my query. Please note that I have changed the names of fields/tables/schema/db, They are all made up names but the logic and layout is same. When I run it, it does not go past the %include statement. It keeps running.. there is no log after that. Hope it helps. Thank you!&lt;/P&gt;&lt;P&gt;------------------------- query --------------------------------------------------------------------&lt;/P&gt;&lt;DIV&gt;&lt;FONT size="3"&gt;%include "Snowflake_libname.sas"; (has libnames)&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="3"&gt;PROC SQL;&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="3"&gt;CONNECT USING SNOW AS SF;&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="3"&gt;CREATE&amp;nbsp; TABLE test AS&amp;nbsp;&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="3"&gt;select * from connection to SF&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="3"&gt;(select DISTINCT&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="3"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; b.cust_nbr&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="3"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;,b.cust_nm&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="3"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;,cast((a.PT_KEY) as varchar(20)) as PT_key&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="3"&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;,c.indvid&amp;nbsp;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="3"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;,c.first_name&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="3"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;,c.last_name&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="3"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;,c.clmnt_dob&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="3"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;,a.dx_code&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="3"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;,d.dx_desc&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="3"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;,a.px_cd&amp;nbsp;&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="3"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;,a.service_dt&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="3"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;,a.process_dt&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="3"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;,a.PD_DT&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="3"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;,e.location&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="3"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;,a.cov_paymt&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="3"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;,a.net_pd_paymt&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="3"&gt;from "db"."schema"."table1" a&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="3"&gt;join "db"."schema"."table2" as b&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="3"&gt;on a.PT_KEY = b.PT_KEY&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="3"&gt;join "db"."schema"."table3" c&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="3"&gt;on a.PT_KEY = c.PT_KEY&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="3"&gt;left join "db"."schema"."table4" d&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="3"&gt;on a.dx_cd = d.dx_cd&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="3"&gt;left join "db"."schema"."table5" e&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="3"&gt;on a.location_cd = e.location_cd&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="3"&gt;where&amp;nbsp;&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="3"&gt;&lt;SPAN&gt;indvid = 1234567&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="3"&gt;and&amp;nbsp; c.first_name='Jane'&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="3"&gt;and c.last_name='Doe'&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="3"&gt;&amp;nbsp;and a.service_dt&amp;nbsp; &amp;gt;= '2024-04-01');&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="3"&gt;quit;&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;</description>
      <pubDate>Tue, 05 May 2026 16:41:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Snowflake-Queries/m-p/987305#M46492</guid>
      <dc:creator>SASMom2</dc:creator>
      <dc:date>2026-05-05T16:41:35Z</dc:date>
    </item>
    <item>
      <title>Re: Snowflake Queries</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Snowflake-Queries/m-p/987448#M46493</link>
      <description>&lt;P&gt;How many observations does that query return?&amp;nbsp; You can test it in Snowflake or just wrap it into something like:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;....
select * from connection to sf
(select count(*) as nobs from
 (... the query goes here ...) a
);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If you want to move a LOT of data then you might get better results using Snowflakes ability to generate a CSV file into some place like Amazon S3 bucket that you could then read with SAS code to make a dataset.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Are any of those variables defined as STRING in Snowflake?&amp;nbsp;&amp;nbsp;SAS datasets only have two types of variables.&amp;nbsp; Fixed length character strings and floating point numbers. So when&amp;nbsp;you have a character variable of unknown length in your Snowflake table&amp;nbsp; SAS will use some default length for the variable when making the dataset.&amp;nbsp; It might pick something very long such as SAS's maximum length of 32,767 bytes.&amp;nbsp; That would make the processes of creating the SAS dataset take a very long time even if the transfer from Snowflake ran quickly.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Try just pulling over a handful of the observations (Snowflake's version of SQL should support something like a LIMIT clause to trim the number of observations returned by the query).&amp;nbsp; You can then run PROC CONTENTS on the resulting SAS dataset and see how the variables are defined.&lt;/P&gt;</description>
      <pubDate>Thu, 07 May 2026 02:43:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Snowflake-Queries/m-p/987448#M46493</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2026-05-07T02:43:05Z</dc:date>
    </item>
  </channel>
</rss>

