<?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: Keep option SQL-Statment in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Keep-option-SQL-Statment/m-p/614924#M179811</link>
    <description>&lt;P&gt;No, in this case the KEEP= option does no good. When you set the data in a data step, you can save some memory and processing time by using the option on the input data, but SQL statements only read the variables that you tell it to. It does no harm either, though.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The KEEP= option may be used with SELECT * in SQL, so that you use the option to limit the variables you want, but I would advise against it in most cases, as explicit variable lists in SQL makes the code easier to read.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The reason you get the messages is because the dataset option is not applicable to the DB2 database, so when you use the option SAS cannot convert the SAS SQL call to native DB2 SQL. It is quite possible that you will get better performance without the KEEP= option, as SAS will then be able to let DB2 handle the whole query.&lt;/P&gt;</description>
    <pubDate>Fri, 03 Jan 2020 08:09:00 GMT</pubDate>
    <dc:creator>s_lassen</dc:creator>
    <dc:date>2020-01-03T08:09:00Z</dc:date>
    <item>
      <title>Keep option SQL-Statment</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Keep-option-SQL-Statment/m-p/614922#M179810</link>
      <description>&lt;P&gt;Hello Everyone,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;does using the "Keep"-Option make sense at all, when quering a Database-Table? Let's assume, I have a Table named "Table1" which has 100 attributes/variables. However, I am only interested in the first variable/attribute ("var1"). The query I, therefore, use is this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
select var1, count(*) as no_obs format = comma20.
from DB2schema.Table1 (&lt;STRONG&gt;keep= var1&lt;/STRONG&gt;)
group by var1;
quit;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;When using extended Messaging Options&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;options dbidirectexec ;
options sastrace=',,,ds' sastraceloc=saslog nostsuffix;
options sql_ip_trace = ALL  msglevel=i;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;I get among other information this relevant sentence:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;P&gt;&lt;STRONG&gt;SAS_SQL: Cannot handle dataset options.&lt;/STRONG&gt;&lt;BR /&gt;SAS_SQL: Unable to convert the query to a DBMS specific SQL statement due to an error.&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;This, to me, suggests, that it is pointless to use the "keep"-option, since the Database cannot handle it, right?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Cheers,&lt;/P&gt;&lt;P&gt;FK&lt;/P&gt;</description>
      <pubDate>Fri, 03 Jan 2020 08:48:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Keep-option-SQL-Statment/m-p/614922#M179810</guid>
      <dc:creator>FK1</dc:creator>
      <dc:date>2020-01-03T08:48:05Z</dc:date>
    </item>
    <item>
      <title>Re: Keep option SQL-Statment</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Keep-option-SQL-Statment/m-p/614924#M179811</link>
      <description>&lt;P&gt;No, in this case the KEEP= option does no good. When you set the data in a data step, you can save some memory and processing time by using the option on the input data, but SQL statements only read the variables that you tell it to. It does no harm either, though.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The KEEP= option may be used with SELECT * in SQL, so that you use the option to limit the variables you want, but I would advise against it in most cases, as explicit variable lists in SQL makes the code easier to read.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The reason you get the messages is because the dataset option is not applicable to the DB2 database, so when you use the option SAS cannot convert the SAS SQL call to native DB2 SQL. It is quite possible that you will get better performance without the KEEP= option, as SAS will then be able to let DB2 handle the whole query.&lt;/P&gt;</description>
      <pubDate>Fri, 03 Jan 2020 08:09:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Keep-option-SQL-Statment/m-p/614924#M179811</guid>
      <dc:creator>s_lassen</dc:creator>
      <dc:date>2020-01-03T08:09:00Z</dc:date>
    </item>
    <item>
      <title>Re: Keep option SQL-Statment</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Keep-option-SQL-Statment/m-p/614929#M179813</link>
      <description>&lt;P&gt;Thank you, &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/76464"&gt;@s_lassen&lt;/a&gt; , for your reply! It is the nuances, that make the difference!&lt;/P&gt;</description>
      <pubDate>Fri, 03 Jan 2020 08:50:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Keep-option-SQL-Statment/m-p/614929#M179813</guid>
      <dc:creator>FK1</dc:creator>
      <dc:date>2020-01-03T08:50:34Z</dc:date>
    </item>
    <item>
      <title>Re: Keep option SQL-Statment</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Keep-option-SQL-Statment/m-p/614953#M179818</link>
      <description>&lt;P&gt;Are you sure the message is accurate for the query you posted?&amp;nbsp; &amp;nbsp;Perhaps the message only applied to any checking that SAS did while compiling the statement to see if VAR1 actually existed on dataset TABLE1.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What SQL do you see in the log that SAS actually pushed into the database?&amp;nbsp; Did it push the group by or pull all of the data and group the data on the SAS side?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 03 Jan 2020 13:02:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Keep-option-SQL-Statment/m-p/614953#M179818</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2020-01-03T13:02:45Z</dc:date>
    </item>
  </channel>
</rss>

