<?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: A data step or macro which is efficient?Give reasons in SAS Data Management</title>
    <link>https://communities.sas.com/t5/SAS-Data-Management/A-data-step-or-macro-which-is-efficient-Give-reasons/m-p/173627#M3424</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The following logic is quicker also. And if you put the IF statements in order of most frequent then that is faster again (US has more rows than EU and EU has more rows than IND).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;SPAN lang="EN-IN" style="font-family: 'Times New Roman', 'serif'; font-size: 12pt;"&gt;If var3=‘US’ then output US;&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;SPAN lang="EN-IN" style="font-family: 'Times New Roman', 'serif'; font-size: 12pt;"&gt;else If var3=’EU’ then output EU;&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;SPAN lang="EN-IN" style="font-family: 'Times New Roman', 'serif'; font-size: 12pt;"&gt;else If var3=’IND’ then output IND;&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sun, 24 Aug 2014 19:44:15 GMT</pubDate>
    <dc:creator>SASKiwi</dc:creator>
    <dc:date>2014-08-24T19:44:15Z</dc:date>
    <item>
      <title>A data step or macro which is efficient?Give reasons</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/A-data-step-or-macro-which-is-efficient-Give-reasons/m-p/173625#M3422</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P style="margin-bottom: 0.0001pt; text-indent: -0.25in;"&gt;&lt;SPAN lang="EN-IN" style="font-size: 12.0pt; font-family: 'Times New Roman','serif';"&gt;EfEfficiency:&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: 0.0001pt;"&gt;&lt;SPAN lang="EN-IN" style="font-size: 12.0pt; font-family: 'Times New Roman','serif';"&gt;If the dataset has one million of observations, which one of the following program is &lt;STRONG&gt;more&lt;/STRONG&gt; efficient in terms of reducing the cpu time. &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="margin-bottom: 0.0001pt;"&gt;&lt;SPAN lang="EN-IN" style="font-size: 12.0pt; font-family: 'Times New Roman','serif';"&gt;Partial dataset:&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: 0.0001pt;"&gt;&lt;STRONG&gt;&lt;SPAN lang="EN-IN" style="font-size: 12.0pt; font-family: 'Times New Roman','serif';"&gt;Dataset:&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P style="margin-bottom: 0.0001pt;"&gt;&lt;STRONG&gt;&lt;SPAN lang="EN-IN" style="font-size: 12.0pt; font-family: 'Times New Roman','serif';"&gt;Var3 Seq1&amp;nbsp; var1 var2 &lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P style="margin-bottom: 0.0001pt;"&gt;&lt;STRONG&gt;&lt;SPAN lang="EN-IN" style="font-size: 12.0pt; font-family: 'Times New Roman','serif';"&gt;US 100&amp;nbsp; 10&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P style="margin-bottom: 0.0001pt;"&gt;&lt;STRONG&gt;&lt;SPAN lang="EN-IN" style="font-size: 12.0pt; font-family: 'Times New Roman','serif';"&gt;EU 200&amp;nbsp; 20&amp;nbsp;&amp;nbsp;&amp;nbsp; 2&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P style="margin-bottom: 0.0001pt;"&gt;&lt;STRONG&gt;&lt;SPAN lang="EN-IN" style="font-size: 12.0pt; font-family: 'Times New Roman','serif';"&gt;IND 300&amp;nbsp; 30&amp;nbsp;&amp;nbsp;&amp;nbsp; 3&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="margin-bottom: 0.0001pt;"&gt;&lt;STRONG style="text-decoration: underline;"&gt;&lt;SPAN lang="EN-IN" style="font-size: 12.0pt; font-family: 'Times New Roman','serif';"&gt;Program No.1&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P style="margin-bottom: 0.0001pt;"&gt;&lt;STRONG&gt;&lt;SPAN lang="EN-IN" style="font-size: 12.0pt; font-family: 'Times New Roman','serif';"&gt;Data US IND EU;&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P style="margin-bottom: 0.0001pt;"&gt;&lt;STRONG&gt;&lt;SPAN lang="EN-IN" style="font-size: 12.0pt; font-family: 'Times New Roman','serif';"&gt;Set dataset;&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P style="margin-bottom: 0.0001pt;"&gt;&lt;STRONG&gt;&lt;SPAN lang="EN-IN" style="font-size: 12.0pt; font-family: 'Times New Roman','serif';"&gt;If var3=‘US’ then output US;&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P style="margin-bottom: 0.0001pt;"&gt;&lt;STRONG&gt;&lt;SPAN lang="EN-IN" style="font-size: 12.0pt; font-family: 'Times New Roman','serif';"&gt;If var3=’EU’ then output EU;&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P style="margin-bottom: 0.0001pt;"&gt;&lt;STRONG&gt;&lt;SPAN lang="EN-IN" style="font-size: 12.0pt; font-family: 'Times New Roman','serif';"&gt;If var3=’IND’ then output IND;&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P style="margin-bottom: 0.0001pt;"&gt;&lt;STRONG&gt;&lt;SPAN lang="EN-IN" style="font-size: 12.0pt; font-family: 'Times New Roman','serif';"&gt;Run;&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="margin-bottom: 0.0001pt;"&gt;&lt;STRONG style="text-decoration: underline;"&gt;&lt;SPAN lang="EN-IN" style="font-size: 12.0pt; font-family: 'Times New Roman','serif';"&gt;Program no. 2&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P style="margin-bottom: 0.0001pt;"&gt;&lt;STRONG&gt;&lt;SPAN lang="EN-IN" style="font-size: 12.0pt; font-family: 'Times New Roman','serif';"&gt;%macro report(country);&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P style="margin-bottom: 0.0001pt;"&gt;&lt;STRONG&gt;&lt;SPAN lang="EN-IN" style="font-size: 12.0pt; font-family: 'Times New Roman','serif';"&gt;Data &amp;amp;country;&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P style="margin-bottom: 0.0001pt;"&gt;&lt;STRONG&gt;&lt;SPAN lang="EN-IN" style="font-size: 12.0pt; font-family: 'Times New Roman','serif';"&gt;Set dataset;&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P style="margin-bottom: 0.0001pt;"&gt;&lt;STRONG&gt;&lt;SPAN lang="EN-IN" style="font-size: 12.0pt; font-family: 'Times New Roman','serif';"&gt;If var3= ‘’&amp;amp;country ‘’ then output &amp;amp;country;&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P style="margin-bottom: 0.0001pt;"&gt;&lt;STRONG&gt;&lt;SPAN lang="EN-IN" style="font-size: 12.0pt; font-family: 'Times New Roman','serif';"&gt;Run;&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P style="margin-bottom: 0.0001pt;"&gt;&lt;STRONG&gt;&lt;SPAN lang="EN-IN" style="font-size: 12.0pt; font-family: 'Times New Roman','serif';"&gt;%mend report;&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P style="margin-bottom: 0.0001pt;"&gt;&lt;STRONG&gt;&lt;SPAN lang="EN-IN" style="font-size: 12.0pt; font-family: 'Times New Roman','serif';"&gt;%report(US)&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P style="margin-bottom: 0.0001pt;"&gt;&lt;STRONG&gt;&lt;SPAN lang="EN-IN" style="font-size: 12.0pt; font-family: 'Times New Roman','serif';"&gt;%report(EU)&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &lt;STRONG&gt;&lt;SPAN lang="EN-IN" style="font-size: 12.0pt; font-family: 'Times New Roman','serif';"&gt;%report(IND)&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 24 Aug 2014 17:43:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/A-data-step-or-macro-which-is-efficient-Give-reasons/m-p/173625#M3422</guid>
      <dc:creator>venkatnaveen</dc:creator>
      <dc:date>2014-08-24T17:43:14Z</dc:date>
    </item>
    <item>
      <title>Re: A data step or macro which is efficient?Give reasons</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/A-data-step-or-macro-which-is-efficient-Give-reasons/m-p/173626#M3423</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I expect program 1 would be faster because it reads the input only once.&lt;/P&gt;&lt;P&gt;Both programs write the same three dataset.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 24 Aug 2014 17:45:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/A-data-step-or-macro-which-is-efficient-Give-reasons/m-p/173626#M3423</guid>
      <dc:creator>Peter_C</dc:creator>
      <dc:date>2014-08-24T17:45:41Z</dc:date>
    </item>
    <item>
      <title>Re: A data step or macro which is efficient?Give reasons</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/A-data-step-or-macro-which-is-efficient-Give-reasons/m-p/173627#M3424</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The following logic is quicker also. And if you put the IF statements in order of most frequent then that is faster again (US has more rows than EU and EU has more rows than IND).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;SPAN lang="EN-IN" style="font-family: 'Times New Roman', 'serif'; font-size: 12pt;"&gt;If var3=‘US’ then output US;&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;SPAN lang="EN-IN" style="font-family: 'Times New Roman', 'serif'; font-size: 12pt;"&gt;else If var3=’EU’ then output EU;&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;SPAN lang="EN-IN" style="font-family: 'Times New Roman', 'serif'; font-size: 12pt;"&gt;else If var3=’IND’ then output IND;&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 24 Aug 2014 19:44:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/A-data-step-or-macro-which-is-efficient-Give-reasons/m-p/173627#M3424</guid>
      <dc:creator>SASKiwi</dc:creator>
      <dc:date>2014-08-24T19:44:15Z</dc:date>
    </item>
    <item>
      <title>Re: A data step or macro which is efficient?Give reasons</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/A-data-step-or-macro-which-is-efficient-Give-reasons/m-p/173628#M3425</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Program no 2 shouldn't be allowed, anywhere! A single if with an output... &lt;STRONG&gt;Always&lt;/STRONG&gt; use WHERE in such situations.&lt;/P&gt;&lt;P&gt;Agree with SASkiwi, based on the limited information in the post.&lt;/P&gt;&lt;P&gt;Is this a real use case, or just an educational question?&lt;/P&gt;&lt;P&gt;If the data set (or DBMS table) has many more values for var3 than the mentioned, a macro approach with WHERE could be more efficient, given that var3 is indexed, or the table is partitioned (i.e. Oracle) or clustered (SPDS) by var3.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 25 Aug 2014 14:11:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/A-data-step-or-macro-which-is-efficient-Give-reasons/m-p/173628#M3425</guid>
      <dc:creator>LinusH</dc:creator>
      <dc:date>2014-08-25T14:11:41Z</dc:date>
    </item>
  </channel>
</rss>

