<?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: How do you really get to know that which option and statement is faster? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-do-you-really-get-to-know-that-which-option-and-statement-is/m-p/934356#M367417</link>
    <description>&lt;P&gt;Try your use case yourself. Sometimes IF is faster / better and sometimes WHERE. It all depends on what you are doing.&lt;/P&gt;</description>
    <pubDate>Tue, 02 Jul 2024 02:26:10 GMT</pubDate>
    <dc:creator>SASKiwi</dc:creator>
    <dc:date>2024-07-02T02:26:10Z</dc:date>
    <item>
      <title>How do you really get to know that which option and statement is faster?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-you-really-get-to-know-that-which-option-and-statement-is/m-p/934257#M367390</link>
      <description>&lt;P&gt;Like if i compare IF and WHERE etc etc.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;which statement or option has role in compilation and execution phase?&lt;/P&gt;</description>
      <pubDate>Mon, 01 Jul 2024 13:31:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-you-really-get-to-know-that-which-option-and-statement-is/m-p/934257#M367390</guid>
      <dc:creator>Nipun22</dc:creator>
      <dc:date>2024-07-01T13:31:22Z</dc:date>
    </item>
    <item>
      <title>Re: How do you really get to know that which option and statement is faster?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-you-really-get-to-know-that-which-option-and-statement-is/m-p/934261#M367391</link>
      <description>&lt;P&gt;&lt;A href="https://blogs.sas.com/content/sasdummy/2016/11/27/if-and-where-sas/" target="_blank"&gt;https://blogs.sas.com/content/sasdummy/2016/11/27/if-and-where-sas/&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://documentation.sas.com/doc/en/lestmtsref/3.2/p1cxl8ifdt8u0gn12wqbji8o5fq1.htm" target="_blank"&gt;https://documentation.sas.com/doc/en/lestmtsref/3.2/p1cxl8ifdt8u0gn12wqbji8o5fq1.htm&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 01 Jul 2024 13:52:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-you-really-get-to-know-that-which-option-and-statement-is/m-p/934261#M367391</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2024-07-01T13:52:48Z</dc:date>
    </item>
    <item>
      <title>Re: How do you really get to know that which option and statement is faster?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-you-really-get-to-know-that-which-option-and-statement-is/m-p/934355#M367416</link>
      <description>If I was right, IF statement would get faster if you have a very big table, otherwise WHEN statement get faster.</description>
      <pubDate>Tue, 02 Jul 2024 02:18:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-you-really-get-to-know-that-which-option-and-statement-is/m-p/934355#M367416</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2024-07-02T02:18:20Z</dc:date>
    </item>
    <item>
      <title>Re: How do you really get to know that which option and statement is faster?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-you-really-get-to-know-that-which-option-and-statement-is/m-p/934356#M367417</link>
      <description>&lt;P&gt;Try your use case yourself. Sometimes IF is faster / better and sometimes WHERE. It all depends on what you are doing.&lt;/P&gt;</description>
      <pubDate>Tue, 02 Jul 2024 02:26:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-you-really-get-to-know-that-which-option-and-statement-is/m-p/934356#M367417</guid>
      <dc:creator>SASKiwi</dc:creator>
      <dc:date>2024-07-02T02:26:10Z</dc:date>
    </item>
    <item>
      <title>Re: How do you really get to know that which option and statement is faster?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-you-really-get-to-know-that-which-option-and-statement-is/m-p/934358#M367418</link>
      <description>&lt;P&gt;You can search that if anyone do some tests and post a conclusion, like you may see someone compares different ways to conduct table lookup:&amp;nbsp;&lt;A href="https://support.sas.com/resources/papers/proceedings/proceedings/sugi26/p008-26.pdf" target="_blank" rel="noopener"&gt;Table Look-Up by Direct Addressing: Key-Indexing -- Bitmapping -- Hashing&lt;/A&gt;&amp;nbsp;(It's really a great paper)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Or you can take some tests by yourself.&lt;/P&gt;
&lt;P&gt;There are `find()`, `index()` and `prxmatch()` to search specified string, which one is faster? Here is how I test:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro prog_runtime(prog,reps=20,title=Input Prog);
%local _Rep_ _Start_ _End_ _Dur_ _TimeRec_ _SumTime_ _AvgTime_ _MedTime_;

/*Record time consuming of input prog*/
%let _SumTime_ = 0;
%let _TimeRec_ = ;

%do _Rep_ = 1 %to &amp;amp;Reps.;
  %let _Start_ = %sysfunc(datetime());
  %unquote(&amp;amp;Prog.);
  %let _End_ = %sysfunc(datetime());
  %let _Dur_ = %sysevalf(&amp;amp;_End_. - &amp;amp;_Start_.);
  %let _TimeRec_ = &amp;amp;_TimeRec_. &amp;amp;_Dur_.;
  %let _SumTime_ = %sysevalf(&amp;amp;_SumTime_. + &amp;amp;_Dur_.);
%end;

/*Compute median and mean time consuming*/
%let _AvgTime_ = %sysevalf(&amp;amp;_SumTime_/&amp;amp;Reps.);
%let _MedTime_ = %sysfunc(median(%sysfunc(tranwrd(%cmpres(&amp;amp;_TimeRec_.),%str( ),%str(,))) ));

/*Report test result*/
%put ****************************************;
%put Summary of Run Time of &amp;amp;title.;
%put Sum of Run Time:    %sysfunc(putn(&amp;amp;_SumTime_.,20.4));
%put Mean of Run Time:   %sysfunc(putn(&amp;amp;_AvgTime_.,20.4));
%put Median of Run Time: %sysfunc(putn(&amp;amp;_MedTime_.,20.4));
%put ;
%mend;

option nonotes nosource;
%Prog_RunTime(%nrstr(
data _null_;
  x = 'Text with many blanks.';
  do i = 1 to 1e7;
    y = index(x,'many');
  end;
run;
),title=index());

%Prog_RunTime(%nrstr(
data _null_;
  x = 'Text with many blanks.';
  do i = 1 to 1e7;
    y = find(x,'many');
  end;
run;
),title=find());

%Prog_RunTime(%nrstr(
data _null_;
  x = 'Text with many blanks.';
  do i = 1 to 1e7;
    y = prxmatch('/many/',x);
  end;
run;
),title=prxmatch());
option notes source;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Here is the test result:&lt;/P&gt;
&lt;PRE&gt;****************************************
Summary of Run Time of index()
Sum of Run Time:                  2.2940
Mean of Run Time:                 0.1147
Median of Run Time:               0.1140

****************************************
Summary of Run Time of find()
Sum of Run Time:                  2.8360
Mean of Run Time:                 0.1418
Median of Run Time:               0.1420

****************************************
Summary of Run Time of prxmatch()
Sum of Run Time:                  8.2410
Mean of Run Time:                 0.4121
Median of Run Time:               0.4115&lt;/PRE&gt;
&lt;P&gt;So, if differences of these three functions are ignored, I always choose `index()`.&lt;/P&gt;</description>
      <pubDate>Tue, 02 Jul 2024 04:01:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-you-really-get-to-know-that-which-option-and-statement-is/m-p/934358#M367418</guid>
      <dc:creator>whymath</dc:creator>
      <dc:date>2024-07-02T04:01:56Z</dc:date>
    </item>
  </channel>
</rss>

