<?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: Is combining multiple IFs in 1 data step faster? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Is-combining-multiple-IFs-in-1-data-step-faster/m-p/850207#M336037</link>
    <description>&lt;P&gt;In addition to execution speed there are several things to consider.&lt;/P&gt;
&lt;P&gt;If you create a new named data set for each "if" block then you are duplicating data. With largish sets in some work environments that mean you might run out of your allotted work space. If keep using the same named data set then you have the case of corrupting values or losing records if one of the sets has a logic problem. Which means that you have to go back to a prior step as this would completely replace the existing data. Another issue with same named sets is that if a minor code change is needed you have to rerun multiple sets of code.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;At one time I inherited code that had a number of blocks of "if/then/else" separated out as you describe. By some minor changes, such as use of ARRAYS and SELECT/WHEN instead of If/then I reduced a program from about 10,000 lines of code (that frankly was a bit hard to follow for logic) to about 800 lines.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you find a need for multiple if/then/else if/ then/ else all using a single variable or expression you may want to research the SELECT/WHEN coding block&lt;/P&gt;</description>
    <pubDate>Tue, 20 Dec 2022 11:26:12 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2022-12-20T11:26:12Z</dc:date>
    <item>
      <title>Is combining multiple IFs in 1 data step faster?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Is-combining-multiple-IFs-in-1-data-step-faster/m-p/850179#M336022</link>
      <description>&lt;P&gt;Hi Everyone,&lt;/P&gt;
&lt;P&gt;I am just curious which method is fast:&lt;/P&gt;
&lt;P&gt;1 - Put multiple (If else then)&amp;nbsp;(If else then)&amp;nbsp; in 1 data step&lt;/P&gt;
&lt;P&gt;2 - Using multiple data step and each contains only 1&amp;nbsp;(If else then)&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Or in general when combining multiple operations in 1 data step is faster than breaking into multiple data steps.&lt;/P&gt;
&lt;P&gt;Thank you for your advice.&lt;/P&gt;
&lt;P&gt;HHC&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 17 Dec 2022 05:09:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Is-combining-multiple-IFs-in-1-data-step-faster/m-p/850179#M336022</guid>
      <dc:creator>hhchenfx</dc:creator>
      <dc:date>2022-12-17T05:09:18Z</dc:date>
    </item>
    <item>
      <title>Re: Is combining multiple IFs in 1 data step faster?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Is-combining-multiple-IFs-in-1-data-step-faster/m-p/850181#M336023</link>
      <description>Using a single data step will always be faster. No comparison! Why not test it yourself?&lt;BR /&gt;&lt;BR /&gt;Here's a program that let's you create a large data set for testing purposes.  It's easy to adjust the size of the data set as needed:&lt;BR /&gt;&lt;BR /&gt;data want;&lt;BR /&gt;do var1 = 1 to 10000000;&lt;BR /&gt;   Output;&lt;BR /&gt;end;&lt;BR /&gt;stop;&lt;BR /&gt;retain var2-var500 0;&lt;BR /&gt;run;</description>
      <pubDate>Sat, 17 Dec 2022 06:26:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Is-combining-multiple-IFs-in-1-data-step-faster/m-p/850181#M336023</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2022-12-17T06:26:53Z</dc:date>
    </item>
    <item>
      <title>Re: Is combining multiple IFs in 1 data step faster?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Is-combining-multiple-IFs-in-1-data-step-faster/m-p/850183#M336025</link>
      <description>&lt;P&gt;One of the golden rules for efficient SAS programming is to minimise the number of passes through your data and that applies to both DATA and PROC steps. So that means the less DATA and PROC steps you have the more efficient they will be.&lt;/P&gt;</description>
      <pubDate>Sat, 17 Dec 2022 07:59:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Is-combining-multiple-IFs-in-1-data-step-faster/m-p/850183#M336025</guid>
      <dc:creator>SASKiwi</dc:creator>
      <dc:date>2022-12-17T07:59:21Z</dc:date>
    </item>
    <item>
      <title>Re: Is combining multiple IFs in 1 data step faster?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Is-combining-multiple-IFs-in-1-data-step-faster/m-p/850185#M336027</link>
      <description>&lt;P&gt;A resounding yes for 1).&lt;/P&gt;
&lt;P&gt;Create a sufficiently large (~ a million obs) dataset and apply Maxim 4.&lt;/P&gt;</description>
      <pubDate>Sat, 17 Dec 2022 08:03:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Is-combining-multiple-IFs-in-1-data-step-faster/m-p/850185#M336027</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2022-12-17T08:03:16Z</dc:date>
    </item>
    <item>
      <title>Re: Is combining multiple IFs in 1 data step faster?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Is-combining-multiple-IFs-in-1-data-step-faster/m-p/850207#M336037</link>
      <description>&lt;P&gt;In addition to execution speed there are several things to consider.&lt;/P&gt;
&lt;P&gt;If you create a new named data set for each "if" block then you are duplicating data. With largish sets in some work environments that mean you might run out of your allotted work space. If keep using the same named data set then you have the case of corrupting values or losing records if one of the sets has a logic problem. Which means that you have to go back to a prior step as this would completely replace the existing data. Another issue with same named sets is that if a minor code change is needed you have to rerun multiple sets of code.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;At one time I inherited code that had a number of blocks of "if/then/else" separated out as you describe. By some minor changes, such as use of ARRAYS and SELECT/WHEN instead of If/then I reduced a program from about 10,000 lines of code (that frankly was a bit hard to follow for logic) to about 800 lines.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you find a need for multiple if/then/else if/ then/ else all using a single variable or expression you may want to research the SELECT/WHEN coding block&lt;/P&gt;</description>
      <pubDate>Tue, 20 Dec 2022 11:26:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Is-combining-multiple-IFs-in-1-data-step-faster/m-p/850207#M336037</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2022-12-20T11:26:12Z</dc:date>
    </item>
    <item>
      <title>Re: Is combining multiple IFs in 1 data step faster?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Is-combining-multiple-IFs-in-1-data-step-faster/m-p/850420#M336103</link>
      <description>&lt;P&gt;Thank you All for the information.&lt;/P&gt;
&lt;P&gt;HHC&lt;/P&gt;</description>
      <pubDate>Tue, 20 Dec 2022 03:10:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Is-combining-multiple-IFs-in-1-data-step-faster/m-p/850420#M336103</guid>
      <dc:creator>hhchenfx</dc:creator>
      <dc:date>2022-12-20T03:10:26Z</dc:date>
    </item>
  </channel>
</rss>

