<?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: Efficient coding in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Efficient-coding/m-p/142049#M296751</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;Please check this one. this could also help.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A _jive_internal="true" href="https://communities.sas.com/message/172882#172882"&gt;https://communities.sas.com/message/172882#172882&lt;/A&gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Uma Shanker Saini&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 16 Jan 2014 06:05:12 GMT</pubDate>
    <dc:creator>umashankersaini</dc:creator>
    <dc:date>2014-01-16T06:05:12Z</dc:date>
    <item>
      <title>Efficient coding</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Efficient-coding/m-p/142042#M296744</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;i have a piece of code that takes on average 2hrs two run due to the size of the data.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;below is the code sample.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;is there more better way i can code this.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;e.g.&lt;/P&gt;&lt;P&gt;data Data_set_name;&lt;/P&gt;&lt;P&gt; set Data_set_name;&lt;/P&gt;&lt;P&gt; where channel = 'PHONE'&lt;/P&gt;&lt;P&gt; or channel = 'BRN'&lt;/P&gt;&lt;P&gt; or channel = 'BRANCH'&lt;/P&gt;&lt;P&gt; or channel = 'FD'&lt;/P&gt;&lt;P&gt; or channel = 'OKS'&lt;/P&gt;&lt;P&gt; or channel = 'FFI'&lt;/P&gt;&lt;P&gt; or channel = 'FIRSTDIRECT'&lt;/P&gt;&lt;P&gt; or channel = 'OCC'&lt;/P&gt;&lt;P&gt; or channel = 'OTHERCALLCENTRE'&lt;/P&gt;&lt;P&gt; or channel = 'FPAS'&lt;/P&gt;&lt;P&gt; and contacted = "Y"&lt;/P&gt;&lt;P&gt; and Direct_Marketing = "Y";&lt;/P&gt;&lt;P&gt; keep id_no cust_no cust_cde dataset_name date_end channel description purpose prod_hse credit_campaign Direct_Marketing;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jan 2014 12:21:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Efficient-coding/m-p/142042#M296744</guid>
      <dc:creator>EMC9</dc:creator>
      <dc:date>2014-01-15T12:21:43Z</dc:date>
    </item>
    <item>
      <title>Re: Efficient coding</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Efficient-coding/m-p/142043#M296745</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Allistair,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Try this modified version of your data step. It only reads the columns you require into the PDV, and uses shorter where clause condition.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DATA Data_set_name;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; SET Data_set_name(KEEP=id_no cust_no cust_cde dataset_name date_end channel description purpose prod_hse credit_campaign Direct_Marketing&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; WHERE=( channel IN ('PHONE','BRN','BRANCH','FD','OKS','FFI','FIRSTDIRECT','OCC','OTHERCALLCENTRE','FPAS')&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; AND contacted = "Y"&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; AND Direct_Marketing = "Y"));&lt;/P&gt;&lt;P&gt;RUN;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Please keep in mind, performance enhancements do not rely on code modifications only!! Sometimes additional changes will be required in order to enhance response times, such as&lt;/P&gt;&lt;P&gt;1. Adding an index for the channel column. (If contacted and Direct_Marketing only contain Y/N values, then no index required)&lt;/P&gt;&lt;P&gt;2. The Physical location of the data set.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 2.1 Network Access --&amp;gt; Network bandwidth limitation&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 2.2 Database Access --&amp;gt; Changes into the Read Buffer size&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 2.3 Disk --&amp;gt; Change stripe widths of 64 or 128K&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Check the following blog, it includes links for additional insight into resolving performance issues&lt;/P&gt;&lt;P&gt;&lt;A href="http://blogs.sas.com/content/sgf/2013/02/27/improving-performance-determine-the-cause/"&gt;Improving performance: Determine the cause&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Good luck,&lt;/P&gt;&lt;P&gt;Ahmed&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jan 2014 13:38:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Efficient-coding/m-p/142043#M296745</guid>
      <dc:creator>AhmedAl_Attar</dc:creator>
      <dc:date>2014-01-15T13:38:06Z</dc:date>
    </item>
    <item>
      <title>Re: Efficient coding</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Efficient-coding/m-p/142044#M296746</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Please try&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data Data_set_name;&lt;/P&gt;&lt;P&gt;set Data_set_name(keep = id_no cust_no cust_cde dataset_name date_end channel description purpose prod_hse credit_campaign Direct_Marketing);&lt;/P&gt;&lt;P&gt;where prxmatch('/PHONE|BRN|BRANCH|FD|OKS|FFI|FIRSTDIREC|FIRSTDIRECT|OCC|OTHERCALLCENTRE|FPAS/',channel)&amp;gt;0&lt;/P&gt;&lt;P&gt;and contacted='Y' and Direct_Marketing = "Y";&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Jag&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jan 2014 13:48:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Efficient-coding/m-p/142044#M296746</guid>
      <dc:creator>Jagadishkatam</dc:creator>
      <dc:date>2014-01-15T13:48:32Z</dc:date>
    </item>
    <item>
      <title>Re: Efficient coding</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Efficient-coding/m-p/142045#M296747</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Several recommendations that might allow the WHERE statement to evaluate faster.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Examine the percentage of observations that satisfy each condition in the WHERE statement.&amp;nbsp; Reorder the conditions so that the WHERE statement can make a decision as early as possible.&amp;nbsp; For example, if only 5% of the observations meet the condition CONTACTED="Y", place that first:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;where contacted="Y" and&lt;/P&gt;&lt;P&gt; (channel='PHONE' or ... or channel='FPAS')&lt;/P&gt;&lt;P&gt;and Direct_Marketing="Y";&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Next, add those parentheses around the CHANNEL values.&amp;nbsp; When you don't, it gets confusing to interpret and to be confident that you are asking for the right set of observations.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Finally, within the list of CHANNEL values, order them from MOST to LEAST frequent occurrence.&amp;nbsp; Again, that let's the WHERE statement find a match as early as possible so it doesn't have to check the remaining values.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In summary, AND conditions should be ordered from least likely to most likely, but OR conditions should be ordered from most likely to least likely.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Good luck.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jan 2014 14:04:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Efficient-coding/m-p/142045#M296747</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2014-01-15T14:04:26Z</dc:date>
    </item>
    <item>
      <title>Re: Efficient coding</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Efficient-coding/m-p/142046#M296748</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Allistair,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I agree with both of Astounding recommendations and the other that appeared in the other two recommendations I saw (i.e., only keeping the data you need).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;That last one will be most effective if you aren't keeping a lot of variables.&amp;nbsp; I just ran a test case where I was dropping a 1,000 variables from the run and it, alone, caused a 75% reduction in running time.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;However, you will also need to include contacted in your keep statement, but then drop it in your data statement.&amp;nbsp; i.e.:&lt;/P&gt;&lt;P&gt;data Data_set_name4 (drop=contacted);&lt;/P&gt;&lt;P&gt;&amp;nbsp; set Data_set_name (keep=id_no cust_no cust_cde dataset_name&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; date_end channel description purpose prod_hse credit_campaign&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Direct_Marketing contacted);&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jan 2014 14:14:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Efficient-coding/m-p/142046#M296748</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2014-01-15T14:14:20Z</dc:date>
    </item>
    <item>
      <title>Re: Efficient coding</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Efficient-coding/m-p/142047#M296749</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I agree with the above, and add:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1) +1 for the suggestion to use indexes.&lt;/P&gt;&lt;P&gt;2) We've seen good performance gains by using a "SPDE Work" library.&amp;nbsp; There are some caveats you need to be aware of (see the doc).&amp;nbsp; But, it's really easy to implement:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;libname spdework spde "%sysfunc(pathname(work))" temp=yes;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;data spdework.Data_set_name4 (drop=contacted);&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&amp;nbsp; set spdework.Data_set_name (keep=id_no cust_no cust_cde dataset_name&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; date_end channel description purpose prod_hse credit_campaign&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Direct_Marketing contacted);&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;I'm assuming your source data is a work dataset since it has a one-level name.&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;You can simplify this further by using the options user=spdework; statement.&amp;nbsp; This redirects one level names to the specified library.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jan 2014 14:34:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Efficient-coding/m-p/142047#M296749</guid>
      <dc:creator>ScottBass</dc:creator>
      <dc:date>2014-01-15T14:34:07Z</dc:date>
    </item>
    <item>
      <title>Re: Efficient coding</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Efficient-coding/m-p/142048#M296750</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;On top of all the good advice already given:&lt;/P&gt;&lt;P&gt;- Use option "fullstimer" so you can see in the log where you're actually spending the time &lt;A href="http://support.sas.com/documentation/cdl/en/lrcon/67227/HTML/default/viewer.htm#n014p8dj7c4lqon1ngsytowdqgar.htm" title="http://support.sas.com/documentation/cdl/en/lrcon/67227/HTML/default/viewer.htm#n014p8dj7c4lqon1ngsytowdqgar.htm"&gt;SAS(R) 9.4 Language Reference: Concepts, Second Edition&lt;/A&gt;&lt;/P&gt;&lt;P&gt;- Have permanent datasets compressed to decrease disk I/O.&lt;/P&gt;&lt;P&gt;- If the source data set is stored in a data base: Code your where clause in a way that it gets fully pushed to the data base for execution. Use "OPTIONS SASTRACE=',,,d' SASTRACELOC=SASLOG NOSTSUFFIX;" to see in the log what part of processing actually gets sent to the DB.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If analysing the log using "fullstimer" tells you it's about I/O then the following will be of interest to you:&lt;/P&gt;&lt;P&gt;&lt;A href="http://support.sas.com/documentation/cdl/en/lrcon/67227/HTML/default/viewer.htm#n0a1u9b2buxl5yn1nv12rnoppiip.htm" title="http://support.sas.com/documentation/cdl/en/lrcon/67227/HTML/default/viewer.htm#n0a1u9b2buxl5yn1nv12rnoppiip.htm"&gt;SAS(R) 9.4 Language Reference: Concepts, Second Edition&lt;/A&gt; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 16 Jan 2014 01:35:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Efficient-coding/m-p/142048#M296750</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2014-01-16T01:35:10Z</dc:date>
    </item>
    <item>
      <title>Re: Efficient coding</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Efficient-coding/m-p/142049#M296751</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;Please check this one. this could also help.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A _jive_internal="true" href="https://communities.sas.com/message/172882#172882"&gt;https://communities.sas.com/message/172882#172882&lt;/A&gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Uma Shanker Saini&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 16 Jan 2014 06:05:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Efficient-coding/m-p/142049#M296751</guid>
      <dc:creator>umashankersaini</dc:creator>
      <dc:date>2014-01-16T06:05:12Z</dc:date>
    </item>
    <item>
      <title>Re: Efficient coding</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Efficient-coding/m-p/142050#M296752</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I never noticed that the order in the where cleasu is affecting performance. What is, is the use of index or not. Whether is optimal to create index or not, it is its own subject area which is discussed in each each project I would say... If you decide to have indexes, and your data is in SAS, I would consider SPDE since it handles indexes much more efficient than the Base SAS engine (especially creating and updating).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Then I wonder if your where cleuse is doing what you want, AND ties "harder" than OR, so your logic contacted = "Y" and Direct_Marketing = "Y" is only evaluated for channel FPAS, is that what you want?&lt;/P&gt;&lt;P&gt;Otherwise, replace the whole OR block with an IN(), easier to code, and perhaps avoids simple coding errors...&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 16 Jan 2014 09:14:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Efficient-coding/m-p/142050#M296752</guid>
      <dc:creator>LinusH</dc:creator>
      <dc:date>2014-01-16T09:14:43Z</dc:date>
    </item>
    <item>
      <title>Re: Efficient coding</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Efficient-coding/m-p/142051#M296753</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;LinusH,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I ran a few tests to explore results of changing order in the WHERE statement.&amp;nbsp; I was able to confirm that the order of AND conditions makes a difference, but not the order of OR conditions.&amp;nbsp; Here's one program I used:&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;data test;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; y=5;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; do x=1 to 10000000;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; output; &lt;BR /&gt;&amp;nbsp;&amp;nbsp; end;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; retain var3 - var10 0;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;data test2;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; set test;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; where y &amp;lt; 0 and x &amp;gt; 0;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;data test3;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; set test;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; where x &amp;gt; 0 and y &amp;lt; 0;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In real life, I ran both DATA steps several times to confirm that the CPU time is different.&amp;nbsp; In the case of OR conditions, I suspect that SAS changes them internally, converting them to an IN operator.&amp;nbsp; But I don't think I found the whole story on that.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Of course, the differences will be small because the WHERE statement accounts for just a small percentage of the work in a DATA step.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 16 Jan 2014 15:03:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Efficient-coding/m-p/142051#M296753</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2014-01-16T15:03:35Z</dc:date>
    </item>
    <item>
      <title>Re: Efficient coding</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Efficient-coding/m-p/142052#M296754</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi! I agree with Linus!&amp;nbsp;&amp;nbsp;&amp;nbsp; The WHERE-statements below are exactly the same:&lt;/P&gt;&lt;P&gt; where channel = 'PHONE'&amp;nbsp;&amp;nbsp;&amp;nbsp; or channel = 'BRN'&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; or channel = 'BRANCH'&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; or channel = 'FD'&amp;nbsp;&amp;nbsp;&amp;nbsp; or channel = 'OKS'&lt;/P&gt;&lt;P&gt; or channel = 'FFI'&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; or channel = 'FIRSTDIRECT'&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; or channel = 'OCC'&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; or channel = 'OTHERCALLCENTRE'&lt;/P&gt;&lt;P&gt; or channel = 'FPAS'&amp;nbsp;&amp;nbsp;&amp;nbsp; and contacted = "Y"&amp;nbsp;&amp;nbsp;&amp;nbsp; and Direct_Marketing = "Y";&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;and&lt;/P&gt;&lt;P&gt; where channel = 'PHONE'&amp;nbsp;&amp;nbsp;&amp;nbsp; or channel = 'BRN'&amp;nbsp;&amp;nbsp;&amp;nbsp; or channel = 'BRANCH'&amp;nbsp;&amp;nbsp;&amp;nbsp; or channel = 'FD'&amp;nbsp;&amp;nbsp;&amp;nbsp; or channel = 'OKS'&lt;/P&gt;&lt;P&gt; or channel = 'FFI'&amp;nbsp;&amp;nbsp;&amp;nbsp; or channel = 'FIRSTDIRECT'&amp;nbsp;&amp;nbsp;&amp;nbsp; or channel = 'OCC'&amp;nbsp;&amp;nbsp;&amp;nbsp; or channel = 'OTHERCALLCENTRE'&lt;/P&gt;&lt;P&gt; or (channel = 'FPAS'&amp;nbsp;&amp;nbsp;&amp;nbsp; and contacted = "Y"&amp;nbsp;&amp;nbsp;&amp;nbsp; and Direct_Marketing = "Y");&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Then of course it all depends on "todays data" if it shows up "today", tomorrow, or some other day.To verify that the statements have EXACTLY the same meaning by performing tests, requires a test data set which "spans all the different values". NOT AT ALL easy to build!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 18 Jan 2014 17:23:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Efficient-coding/m-p/142052#M296754</guid>
      <dc:creator>AndersS</dc:creator>
      <dc:date>2014-01-18T17:23:05Z</dc:date>
    </item>
    <item>
      <title>Re: Efficient coding</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Efficient-coding/m-p/142053#M296755</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Yes they are the same, but I really have to wonder if the OP realized that?&amp;nbsp; I.e., I think that the OP has to clarify whether he/she was really trying to accomplish:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;where channel = 'PHONE'&amp;nbsp;&amp;nbsp;&amp;nbsp; or channel = 'BRN'&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; or channel = 'BRANCH'&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; or channel = 'FD'&amp;nbsp;&amp;nbsp;&amp;nbsp; or channel = 'OKS'&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;or channel = 'FFI'&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; or channel = 'FIRSTDIRECT'&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; or channel = 'OCC'&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; or channel = 'OTHERCALLCENTRE'&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;or channel = 'FPAS'&amp;nbsp;&amp;nbsp;&amp;nbsp; and contacted = "Y"&amp;nbsp;&amp;nbsp;&amp;nbsp; and Direct_Marketing = "Y";&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;or&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;where (channel = 'PHONE'&amp;nbsp;&amp;nbsp;&amp;nbsp; or channel = 'BRN'&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; or channel = 'BRANCH'&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; or channel = 'FD'&amp;nbsp;&amp;nbsp;&amp;nbsp; or channel = 'OKS'&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;or channel = 'FFI'&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; or channel = 'FIRSTDIRECT'&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; or channel = 'OCC'&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; or channel = 'OTHERCALLCENTRE'&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;or channel = 'FPAS')&amp;nbsp;&amp;nbsp;&amp;nbsp; and contacted = "Y"&amp;nbsp;&amp;nbsp;&amp;nbsp; and Direct_Marketing = "Y";&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 18 Jan 2014 17:45:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Efficient-coding/m-p/142053#M296755</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2014-01-18T17:45:44Z</dc:date>
    </item>
    <item>
      <title>Re: Efficient coding</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Efficient-coding/m-p/142054#M296756</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi! I agree completely!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 18 Jan 2014 17:52:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Efficient-coding/m-p/142054#M296756</guid>
      <dc:creator>AndersS</dc:creator>
      <dc:date>2014-01-18T17:52:48Z</dc:date>
    </item>
    <item>
      <title>Re: Efficient coding</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Efficient-coding/m-p/142055#M296757</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Yeah, you are correct. And the difference on CPU time is about 20%, so it does have some impact.&lt;/P&gt;&lt;P&gt;I guess that since these variables are not indexed, and therefore have no stats of the contents in the variable, SAS can't guess in what order it should evaluate the where clause. So this is a clear differentiation to RDBMS where you usually have the possibility to calculate statistics for a table, indexed or not.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 18 Jan 2014 18:11:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Efficient-coding/m-p/142055#M296757</guid>
      <dc:creator>LinusH</dc:creator>
      <dc:date>2014-01-18T18:11:09Z</dc:date>
    </item>
    <item>
      <title>Re: Efficient coding</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Efficient-coding/m-p/142056#M296758</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Watch out because AND is evaluated before OR in the order of operations precedence for SAS.&amp;nbsp;&amp;nbsp; &lt;A class="active_link" href="http://v8doc.sas.com/sashtml/lgref/z0208245.htm" style="font-size: 10pt; line-height: 1.5em;" title="http://v8doc.sas.com/sashtml/lgref/z0208245.htm"&gt;SAS Operators : Order of Evaluation of SAS Operators&lt;/A&gt;&lt;/P&gt;&lt;P&gt;Note that SAS will show you how it has interpreted your WHERE condition in the notes.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;52&amp;nbsp;&amp;nbsp; data one ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;53&amp;nbsp;&amp;nbsp;&amp;nbsp; set test;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;54&amp;nbsp;&amp;nbsp;&amp;nbsp; where c=1 or c=2 or c=3 and a and b;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;55&amp;nbsp;&amp;nbsp; run;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;NOTE: There were 9 observations read from the data set WORK.TEST.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; WHERE c in (1, 2) or ((c=3) and a and b);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;56&amp;nbsp;&amp;nbsp; data two;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;57&amp;nbsp;&amp;nbsp;&amp;nbsp; set test;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;58&amp;nbsp;&amp;nbsp;&amp;nbsp; where a and b or c=1 or c=2 or c=3 ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;59&amp;nbsp;&amp;nbsp; run;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;NOTE: There were 14 observations read from the data set WORK.TEST.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; WHERE (a and b) or c in (1, 2, 3);&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 18 Jan 2014 18:15:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Efficient-coding/m-p/142056#M296758</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2014-01-18T18:15:44Z</dc:date>
    </item>
    <item>
      <title>Re: Efficient coding</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Efficient-coding/m-p/142057#M296759</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi! Some years ago I read a very good book about efficient coding. In summary:&amp;nbsp;&amp;nbsp; Solve the correct problem, make sure that your code is as clear and easy to understand as possible. If you have time spend it on documenting the problem and the solution. - When all this has been done - then you can start to experiment with writing the code, so that it runs faster.&lt;BR /&gt;(The book was written in 1966 I think. Efficient Fortran techniques. CPU and IO were VERY expensive at that time). &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 21 Jan 2014 23:25:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Efficient-coding/m-p/142057#M296759</guid>
      <dc:creator>AndersS</dc:creator>
      <dc:date>2014-01-21T23:25:20Z</dc:date>
    </item>
    <item>
      <title>Re: Efficient coding</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Efficient-coding/m-p/142058#M296760</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I/O can be expensive still, in run-time&lt;/P&gt;&lt;P&gt;For that reason, I often create data step views rather than intermediate tables. (but only when the view would be read just once or twice)&lt;/P&gt;&lt;P&gt;The advantage views provide is a major reduction in I/O.&lt;/P&gt;&lt;P&gt;The intermediate data is being created as it is read.&lt;/P&gt;&lt;P&gt;To achieve this, often sort+merge processes are replaced with format/array/hash look-ups.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 23 Jan 2014 13:09:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Efficient-coding/m-p/142058#M296760</guid>
      <dc:creator>Peter_C</dc:creator>
      <dc:date>2014-01-23T13:09:13Z</dc:date>
    </item>
    <item>
      <title>Re: Efficient coding</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Efficient-coding/m-p/142059#M296761</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Peter! I DO agree about Data Step view. I have used them several times, which resulted in great reductions in computer resources needed.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 24 Jan 2014 09:54:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Efficient-coding/m-p/142059#M296761</guid>
      <dc:creator>AndersS</dc:creator>
      <dc:date>2014-01-24T09:54:02Z</dc:date>
    </item>
    <item>
      <title>Re: Efficient coding</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Efficient-coding/m-p/142060#M296762</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Views can be very helpful. I've made the experience though that when "nesting" too many SAS SQL views it can have a negative impact on performance. "The theory" is that this is due to the SQL optimizer no more properly optimizing the SQL.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 24 Jan 2014 12:13:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Efficient-coding/m-p/142060#M296762</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2014-01-24T12:13:21Z</dc:date>
    </item>
    <item>
      <title>Re: Efficient coding</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Efficient-coding/m-p/142061#M296763</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN&gt;It's probably inevitable that the optimizers have a limit to the resources they can use to "layer" the views. Each time I have had to trial with high volume data to ensure production processes will be resilient. &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;As usual, there are trade-offs between I/O and cpu time.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 24 Jan 2014 12:36:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Efficient-coding/m-p/142061#M296763</guid>
      <dc:creator>Peter_C</dc:creator>
      <dc:date>2014-01-24T12:36:48Z</dc:date>
    </item>
  </channel>
</rss>

