<?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: Reading data from Work takes long time in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Reading-data-from-Work-takes-long-time/m-p/430249#M281585</link>
    <description>&lt;P&gt;Work shouldn’t be the issue for your second query.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Hoeever when you’re pulling data from different sources, ie WORK and a server somewhere else, SAS first brings it all in, which is what slows things down. So the fact that your join is slow Is not surprising. The fact that a plain select takes long doesn’t make sense however.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/188750"&gt;@leok31&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;I'm new SAS and still learning my way around.&lt;/P&gt;
&lt;P&gt;I've connected to SQL Server via SAS using ODBC connection.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I used PROC SQL statement to create a table, this took around 10 second.&lt;/P&gt;
&lt;P&gt;But then, when I try to query that table it takes a long time. So far I waited 8 min before stopping the process.&lt;/P&gt;
&lt;P&gt;Similar thing happens when I try to JOIN the newly created table to another table from SQL Server.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Is there anything I can do to speed up the process?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here is the code that I'm using&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
 CREATE TABLE ActiveIB as 
SELECT distinct col1
      ,col2
      ,col3
      
  FROM CAM.FactTable
  where Col4= 'Active'
  and (DateCol is  NULL or  DateCol &amp;lt;= '01DEC2017'd)
  ;
  
  quit;&lt;BR /&gt;&lt;BR /&gt;proc sql outobs=10;&lt;BR /&gt;select *&lt;BR /&gt;from ActiveIB&lt;BR /&gt;;&lt;BR /&gt;quit;&lt;/CODE&gt;&lt;/PRE&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;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 24 Jan 2018 02:01:46 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2018-01-24T02:01:46Z</dc:date>
    <item>
      <title>Reading data from Work takes long time</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reading-data-from-Work-takes-long-time/m-p/430241#M281583</link>
      <description>&lt;P&gt;I'm new SAS and still learning my way around.&lt;/P&gt;&lt;P&gt;I've connected to SQL Server via SAS using ODBC connection.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I used PROC SQL statement to create a table, this took around 10 second.&lt;/P&gt;&lt;P&gt;But then, when I try to query that table it takes a long time. So far I waited 8 min before stopping the process.&lt;/P&gt;&lt;P&gt;Similar thing happens when I try to JOIN the newly created table to another table from SQL Server.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is there anything I can do to speed up the process?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is the code that I'm using&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
 CREATE TABLE ActiveIB as 
SELECT distinct col1
      ,col2
      ,col3
      
  FROM CAM.FactTable
  where Col4= 'Active'
  and (DateCol is  NULL or  DateCol &amp;lt;= '01DEC2017'd)
  ;
  
  quit;&lt;BR /&gt;&lt;BR /&gt;proc sql outobs=10;&lt;BR /&gt;select *&lt;BR /&gt;from ActiveIB&lt;BR /&gt;;&lt;BR /&gt;quit;&lt;/CODE&gt;&lt;/PRE&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>Wed, 24 Jan 2018 01:18:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reading-data-from-Work-takes-long-time/m-p/430241#M281583</guid>
      <dc:creator>leok31</dc:creator>
      <dc:date>2018-01-24T01:18:28Z</dc:date>
    </item>
    <item>
      <title>Re: Reading data from Work takes long time</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reading-data-from-Work-takes-long-time/m-p/430243#M281584</link>
      <description>&lt;P&gt;I suspect your second SQL query is reading all of your data. Try this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc print data = ActiveIB (obs = 10);
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 24 Jan 2018 01:32:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reading-data-from-Work-takes-long-time/m-p/430243#M281584</guid>
      <dc:creator>SASKiwi</dc:creator>
      <dc:date>2018-01-24T01:32:20Z</dc:date>
    </item>
    <item>
      <title>Re: Reading data from Work takes long time</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reading-data-from-Work-takes-long-time/m-p/430249#M281585</link>
      <description>&lt;P&gt;Work shouldn’t be the issue for your second query.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Hoeever when you’re pulling data from different sources, ie WORK and a server somewhere else, SAS first brings it all in, which is what slows things down. So the fact that your join is slow Is not surprising. The fact that a plain select takes long doesn’t make sense however.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/188750"&gt;@leok31&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;I'm new SAS and still learning my way around.&lt;/P&gt;
&lt;P&gt;I've connected to SQL Server via SAS using ODBC connection.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I used PROC SQL statement to create a table, this took around 10 second.&lt;/P&gt;
&lt;P&gt;But then, when I try to query that table it takes a long time. So far I waited 8 min before stopping the process.&lt;/P&gt;
&lt;P&gt;Similar thing happens when I try to JOIN the newly created table to another table from SQL Server.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Is there anything I can do to speed up the process?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here is the code that I'm using&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
 CREATE TABLE ActiveIB as 
SELECT distinct col1
      ,col2
      ,col3
      
  FROM CAM.FactTable
  where Col4= 'Active'
  and (DateCol is  NULL or  DateCol &amp;lt;= '01DEC2017'd)
  ;
  
  quit;&lt;BR /&gt;&lt;BR /&gt;proc sql outobs=10;&lt;BR /&gt;select *&lt;BR /&gt;from ActiveIB&lt;BR /&gt;;&lt;BR /&gt;quit;&lt;/CODE&gt;&lt;/PRE&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;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 24 Jan 2018 02:01:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reading-data-from-Work-takes-long-time/m-p/430249#M281585</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-01-24T02:01:46Z</dc:date>
    </item>
    <item>
      <title>Re: Reading data from Work takes long time</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reading-data-from-Work-takes-long-time/m-p/430265#M281586</link>
      <description>&lt;P&gt;For some reason, selecting just the top 10 is now working fine.&lt;/P&gt;&lt;P&gt;Selecting all the rows still takes a very long time, it's only 300k rows. Why would it take so long if the data is stored in Work library and not on an external server?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 24 Jan 2018 03:10:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reading-data-from-Work-takes-long-time/m-p/430265#M281586</guid>
      <dc:creator>leok31</dc:creator>
      <dc:date>2018-01-24T03:10:20Z</dc:date>
    </item>
    <item>
      <title>Re: Reading data from Work takes long time</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reading-data-from-Work-takes-long-time/m-p/430271#M281587</link>
      <description>&lt;P&gt;Post the SAS log of your program including the notes on how long it took so we can provide further advice.&lt;/P&gt;</description>
      <pubDate>Wed, 24 Jan 2018 03:44:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reading-data-from-Work-takes-long-time/m-p/430271#M281587</guid>
      <dc:creator>SASKiwi</dc:creator>
      <dc:date>2018-01-24T03:44:41Z</dc:date>
    </item>
    <item>
      <title>Re: Reading data from Work takes long time</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reading-data-from-Work-takes-long-time/m-p/430290#M281588</link>
      <description>&lt;P&gt;The query has been running for over 30 min.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm running SAS Studio, so I had to cancel it and it results in termination of the session. I can't get any log data for it.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 24 Jan 2018 04:49:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reading-data-from-Work-takes-long-time/m-p/430290#M281588</guid>
      <dc:creator>leok31</dc:creator>
      <dc:date>2018-01-24T04:49:39Z</dc:date>
    </item>
    <item>
      <title>Re: Reading data from Work takes long time</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reading-data-from-Work-takes-long-time/m-p/430673#M281589</link>
      <description>&lt;P&gt;1- Just checking: your CAM library uses the ODBC engine to point to SQL Server?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;2- Use&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt; options sastrace=',,,d' sastraceloc=saslog nostsuffix dbidirectexec ;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;to see what query is sent to SQL server.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;3- Use dataset option&lt;FONT face="courier new,courier"&gt;(obs=10)&lt;/FONT&gt; to limit the number of rows so we can get a log.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;4- Run the query and post the log.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 24 Jan 2018 20:51:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reading-data-from-Work-takes-long-time/m-p/430673#M281589</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2018-01-24T20:51:03Z</dc:date>
    </item>
  </channel>
</rss>

