<?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: Efficiency Intuition help: Few small steps vs One mega step in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Efficiency-Intuition-help-Few-small-steps-vs-One-mega-step/m-p/488774#M287408</link>
    <description>&lt;P&gt;1. A multitude of tiny steps is not necessarily easier to read than fewer larger steps.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;2. From a performance perspective, I/O is usually the killer in BI jobs as &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13674"&gt;@LinusH&lt;/a&gt;&amp;nbsp;said, and so fewer steps are generally faster as long as the I/Os are kept sequential (which was probably not the case in&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/11562"&gt;@Kurt_Bremser&lt;/a&gt;'s SQL example) as they limit I/Os.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;3. Sometimes, one has to weigh legibility vs performance. If one optimised, sequential step takes 12 hours to run, maybe it should be kept whole&amp;nbsp;even if harder to decipher due to more convoluted data manipulation than what simpler and easier-to-read steps could do in twice the time.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;4. It all depends. To quote&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13674"&gt;@LinusH&lt;/a&gt;&lt;SPAN&gt;: "&lt;/SPAN&gt;It's an art"&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 22 Aug 2018 06:01:13 GMT</pubDate>
    <dc:creator>ChrisNZ</dc:creator>
    <dc:date>2018-08-22T06:01:13Z</dc:date>
    <item>
      <title>Efficiency Intuition help: Few small steps vs One mega step</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Efficiency-Intuition-help-Few-small-steps-vs-One-mega-step/m-p/488374#M287401</link>
      <description>&lt;P&gt;Efficiency Intuition help: Few small steps vs One mega step&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I would like to seek your opinion and guidance on how to foresee or think through the objective of writing a program that executes the fastest and efficient manner. Sometimes, the assumption for many is to program all in one step as opposed to otherwise mentioned in the subject.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Of course I understand this topic is highly dependent upon the quality of the programmer, however when taking relatively simple examples, it sometimes baffles me that small "n" many steps executes as whole much faster than "n=1" step. How do I gain this intuitive ability in the first place before writing both forms and testing it to see - &lt;EM&gt;"Oh well, is this all it does after all"&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Note, @&lt;SPAN&gt;SAS L&amp;nbsp;&lt;/SPAN&gt;Hall of famers&amp;nbsp; et al and top users,&amp;nbsp; your programs are excluded from this comparison study coz I know your one step solution will likely win 99% of the times, nevertheless this is very intriguing.&lt;/P&gt;</description>
      <pubDate>Mon, 20 Aug 2018 21:48:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Efficiency-Intuition-help-Few-small-steps-vs-One-mega-step/m-p/488374#M287401</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2018-08-20T21:48:23Z</dc:date>
    </item>
    <item>
      <title>Re: Efficiency Intuition help: Few small steps vs One mega step</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Efficiency-Intuition-help-Few-small-steps-vs-One-mega-step/m-p/488392#M287402</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/138205"&gt;@novinosrin&lt;/a&gt;: It would help if you can post an example where many small steps works faster than having everything in one step.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;One way in insure that times will increase is to read data more times than necessary. That is what typically occurs when one programs with multiple steps, rather than doing everything in a single step. Additionally, IMHO, breaking a program into multiple steps makes it harder for someone else to follow what you've done.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Art, CEO, AnalystFinder.com&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 20 Aug 2018 23:59:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Efficiency-Intuition-help-Few-small-steps-vs-One-mega-step/m-p/488392#M287402</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2018-08-20T23:59:01Z</dc:date>
    </item>
    <item>
      <title>Re: Efficiency Intuition help: Few small steps vs One mega step</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Efficiency-Intuition-help-Few-small-steps-vs-One-mega-step/m-p/488441#M287403</link>
      <description>&lt;P&gt;Personally, I prefer to work in steps. This is also covered in Maxim 34.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;My object lesson for this came early when I reviewed a consultant's code that merged 5 normalized tables into one dataset for analysis. His code contained &amp;gt; 10 separate sort and data steps. My first thought was "I can do that in one easy SQL!", and so I did that. My nice&amp;amp;easy SQL took 4 hours to finish, his two-page sort/merge sequence just 20 minutes.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;OTOH, one can hare off into the wrong direction:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data Asia;
set sashelp.cars;
where Origin = 'Asia';
run;

data Europe;
set sashelp.cars;
where Origin = 'Europe';
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;vs.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data
  Asia
  Europe
;
set sashelp.cars;
select (Origin);
  when ('Asia') output Asia;
  when ('Europe') output Europe;
  otherwise;
end;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The second code will clearly outperform the first, and splitting the dataset is one functional unit, so it obviously does not violate Maxim 34.&lt;/P&gt;</description>
      <pubDate>Tue, 21 Aug 2018 07:18:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Efficiency-Intuition-help-Few-small-steps-vs-One-mega-step/m-p/488441#M287403</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-08-21T07:18:10Z</dc:date>
    </item>
    <item>
      <title>Re: Efficiency Intuition help: Few small steps vs One mega step</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Efficiency-Intuition-help-Few-small-steps-vs-One-mega-step/m-p/488486#M287404</link>
      <description>&lt;P&gt;I would pick up "&amp;nbsp;&lt;SPAN&gt;Few small steps " .&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;"One mega step" would make code very complicated and lead you to more ERROR.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;The RIGHT result is first.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 21 Aug 2018 10:33:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Efficiency-Intuition-help-Few-small-steps-vs-One-mega-step/m-p/488486#M287404</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2018-08-21T10:33:36Z</dc:date>
    </item>
    <item>
      <title>Re: Efficiency Intuition help: Few small steps vs One mega step</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Efficiency-Intuition-help-Few-small-steps-vs-One-mega-step/m-p/488603#M287405</link>
      <description>Programming is not scientific, it's an art. So therefore there will never be a clear correct answer. &lt;BR /&gt;Personally I first see to reduce no of steps, as long as the logic is somewhat clear. Where to draw the line is up to you, and perhaps the maintenance people who will live with the developed solution.</description>
      <pubDate>Tue, 21 Aug 2018 14:52:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Efficiency-Intuition-help-Few-small-steps-vs-One-mega-step/m-p/488603#M287405</guid>
      <dc:creator>LinusH</dc:creator>
      <dc:date>2018-08-21T14:52:23Z</dc:date>
    </item>
    <item>
      <title>Re: Efficiency Intuition help: Few small steps vs One mega step</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Efficiency-Intuition-help-Few-small-steps-vs-One-mega-step/m-p/488640#M287406</link>
      <description>&lt;P&gt;Very very interesting point of view/comments from all of you. I am hoping and expecting a few more to chime in their views and draw inferences from opinions.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here is my Professor's view I am sharing coz he isn't on this community nor a sas user:&lt;/P&gt;
&lt;P&gt;1. Construct/Building block&amp;nbsp; should be &lt;STRONG&gt;&lt;U&gt;small to very small&lt;/U&gt;&lt;/STRONG&gt; if broken into few small steps. This could challenge heavy looping in mega steps&amp;nbsp;&lt;/P&gt;
&lt;P&gt;2.&amp;nbsp; Only use mega step if it;s not possible to have small to very small building blocks, coz in essence the effort is the same.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Example,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;1. In instances, like sort, create grouping var and then do proc summary/sql (2 steps) easier to understand with very short programs&lt;/P&gt;
&lt;P&gt;2. Or manage with array feeds, hash instances(Hash of hash eg) etc and of course making it look brilliant and classy although intimidating for intermediates&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The 2nd will of course be the charm of greats like all of you who have chimed in here as I am well aware of your expertise however just looking through the lens of semi technical audiences makes me wonder how much of that is appreciated by those folks as a whole.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you for your time!&lt;/P&gt;</description>
      <pubDate>Tue, 21 Aug 2018 17:07:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Efficiency-Intuition-help-Few-small-steps-vs-One-mega-step/m-p/488640#M287406</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2018-08-21T17:07:23Z</dc:date>
    </item>
    <item>
      <title>Re: Efficiency Intuition help: Few small steps vs One mega step</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Efficiency-Intuition-help-Few-small-steps-vs-One-mega-step/m-p/488650#M287407</link>
      <description>From a logical perspective I can agree. But the recommendation seems generic and perhaps optimal for application development outside the BI domain. In ETL, IO is the primary area of performance tuning.</description>
      <pubDate>Tue, 21 Aug 2018 17:50:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Efficiency-Intuition-help-Few-small-steps-vs-One-mega-step/m-p/488650#M287407</guid>
      <dc:creator>LinusH</dc:creator>
      <dc:date>2018-08-21T17:50:53Z</dc:date>
    </item>
    <item>
      <title>Re: Efficiency Intuition help: Few small steps vs One mega step</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Efficiency-Intuition-help-Few-small-steps-vs-One-mega-step/m-p/488774#M287408</link>
      <description>&lt;P&gt;1. A multitude of tiny steps is not necessarily easier to read than fewer larger steps.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;2. From a performance perspective, I/O is usually the killer in BI jobs as &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13674"&gt;@LinusH&lt;/a&gt;&amp;nbsp;said, and so fewer steps are generally faster as long as the I/Os are kept sequential (which was probably not the case in&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/11562"&gt;@Kurt_Bremser&lt;/a&gt;'s SQL example) as they limit I/Os.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;3. Sometimes, one has to weigh legibility vs performance. If one optimised, sequential step takes 12 hours to run, maybe it should be kept whole&amp;nbsp;even if harder to decipher due to more convoluted data manipulation than what simpler and easier-to-read steps could do in twice the time.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;4. It all depends. To quote&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13674"&gt;@LinusH&lt;/a&gt;&lt;SPAN&gt;: "&lt;/SPAN&gt;It's an art"&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 22 Aug 2018 06:01:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Efficiency-Intuition-help-Few-small-steps-vs-One-mega-step/m-p/488774#M287408</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2018-08-22T06:01:13Z</dc:date>
    </item>
    <item>
      <title>Re: Efficiency Intuition help: Few small steps vs One mega step</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Efficiency-Intuition-help-Few-small-steps-vs-One-mega-step/m-p/488778#M287409</link>
      <description>&lt;P&gt;I even have a Maxim for that (30). One can have easy-to-read code that is very inefficient if that step still doesn't take more than 20 seconds or so. If you can shave off hours (or, in some environments, even just minutes) by engaging in some less-easy-to-decipher coding, then you probably want to do it.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In my original example, the SAS SQL strategy of throwing everything into the utility file and working off that with lots of random reads caused the WORK disks to slow dosn to a crawl. Since the sequence of sort/data steps engaged mainly in sequential read/write operations (and one can even split the load over disk arrays by using physically separate libraries when you do it manually), it outperformed SQL by orders of magnitude.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Keeping a sequence of steps legible is also part of the "art". In my experience, I've found it easier to grok what separate steps do. I absolutely hate to read myself into those complex SQL queries that involve multiple, often nested, subqueries. The usual straightforward style that I find in our host PL/1 programs OTOH&amp;nbsp;is easy&amp;nbsp;for me. On top of SAS and PL/1 sharing the basic syntax.&lt;/P&gt;</description>
      <pubDate>Wed, 22 Aug 2018 06:16:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Efficiency-Intuition-help-Few-small-steps-vs-One-mega-step/m-p/488778#M287409</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-08-22T06:16:50Z</dc:date>
    </item>
  </channel>
</rss>

