<?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: Start a process when start_variable=1 in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Start-a-process-when-start-variable-1/m-p/230458#M268057</link>
    <description>&lt;P&gt;I'm not certain I understand fully. It seems like you want to compare &lt;EM&gt;value&lt;/EM&gt; with the preceeding 10 values and set &lt;EM&gt;ROC_rank&lt;/EM&gt; based on the ranking of &lt;EM&gt;value&lt;/EM&gt; relative to the set of 10. Furthermore, you want output only for cases where &lt;EM&gt;start&lt;/EM&gt;=1. The role of variable &lt;EM&gt;order&lt;/EM&gt; is undefined. This would do that:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
set have;
array a{0:9} _temporary_;
if start and nmiss(of a{*})=0 then do;
    if      value&amp;gt;=largest(1,of a{*}) then ROC_rank=5;
    else if value&amp;gt;=largest(2,of a{*}) then ROC_rank=4;
    else if value&amp;gt;=largest(3,of a{*}) then ROC_rank=3;
    else if value&amp;gt;=largest(4,of a{*}) then ROC_rank=1.5;
    else                                   ROC_rank=0.1;
    output;
    end;
a{mod(_n_,10)}=value;
run;&lt;/CODE&gt;&amp;nbsp;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sun, 18 Oct 2015 03:53:41 GMT</pubDate>
    <dc:creator>PGStats</dc:creator>
    <dc:date>2015-10-18T03:53:41Z</dc:date>
    <item>
      <title>Start a process when start_variable=1</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Start-a-process-when-start-variable-1/m-p/230452#M268054</link>
      <description>&lt;P&gt;Hi Everyone,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have a start variable having value 1.&lt;/P&gt;
&lt;P&gt;When value =1, I want to run the below 2 data steps.&lt;/P&gt;
&lt;P&gt;Of course, I can&amp;nbsp;run the whole process on every single record but it is not optimal.&lt;/P&gt;
&lt;P&gt;I appreciate it if you could help me.&lt;/P&gt;
&lt;P&gt;HHC&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data have;&lt;BR /&gt;input start order value;&lt;BR /&gt;datalines;&lt;BR /&gt;0 1 5&lt;BR /&gt;0 2 2&lt;BR /&gt;0 3 4&lt;BR /&gt;0 4 4&lt;BR /&gt;0 5 5&lt;BR /&gt;0 6 2&lt;BR /&gt;0 7 7&lt;BR /&gt;0 8 1&lt;BR /&gt;0 9 13&lt;BR /&gt;0 1 10 5&lt;BR /&gt;0 1 56&lt;BR /&gt;0 2 26&lt;BR /&gt;0 3 46&lt;BR /&gt;0 4 46&lt;BR /&gt;0 5 18&lt;BR /&gt;0 6 58&lt;BR /&gt;0 7 8&lt;BR /&gt;0 8 2&lt;BR /&gt;0 9 100&lt;BR /&gt;1 10 5&lt;BR /&gt;;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;IF START=1 THEN DO THE FOLLOWING PROCESS&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data want;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;set have;&lt;BR /&gt;drop aa1-aa10;&lt;BR /&gt;array a{0:9} aa1-aa10;&lt;BR /&gt;retain aa:;&lt;BR /&gt;pct_60=largest((10-10*60/100+1),of a{*}); &lt;BR /&gt;pct_70=largest((10-10*70/100+1),of a{*}); &lt;BR /&gt;pct_80=largest((10-10*80/100+1),of a{*});&lt;BR /&gt;pct_90=largest((10-10*90/100+1),of a{*});&lt;BR /&gt;a{mod(_n_,10)}=value;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;data want; set want;&lt;BR /&gt;drop pct_25-pct_100 ;&lt;BR /&gt;if value&amp;gt;=pct_90 then ROC_rank=5;&lt;BR /&gt;else if value&amp;gt;=pct_80 then ROC_rank=4;&lt;BR /&gt;else if value&amp;gt;=pct_70 then ROC_rank=3;&lt;BR /&gt;else if value&amp;gt;=pct_60 then ROC_rank=1.5;&lt;BR /&gt;else ROC_rank=0.1;&lt;BR /&gt;run;&lt;/P&gt;</description>
      <pubDate>Sun, 18 Oct 2015 03:04:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Start-a-process-when-start-variable-1/m-p/230452#M268054</guid>
      <dc:creator>hhchenfx</dc:creator>
      <dc:date>2015-10-18T03:04:31Z</dc:date>
    </item>
    <item>
      <title>Re: Start a process when start_variable=1</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Start-a-process-when-start-variable-1/m-p/230454#M268055</link>
      <description>&lt;P&gt;Your example code generates an error: it is interrupted because of looping. What is it intended to do?&lt;/P&gt;</description>
      <pubDate>Sun, 18 Oct 2015 02:38:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Start-a-process-when-start-variable-1/m-p/230454#M268055</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2015-10-18T02:38:13Z</dc:date>
    </item>
    <item>
      <title>Re: Start a process when start_variable=1</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Start-a-process-when-start-variable-1/m-p/230455#M268056</link>
      <description>&lt;P&gt;Sorry for not deleting the IF statement.&lt;/P&gt;
&lt;P&gt;Here is the clean one.&lt;/P&gt;
&lt;P&gt;Thank you for helping, PGStats.&lt;/P&gt;
&lt;P&gt;HHC&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data have;&lt;BR /&gt;input start order value;&lt;BR /&gt;datalines;&lt;BR /&gt;0 1 5&lt;BR /&gt;0 2 2&lt;BR /&gt;0 3 4&lt;BR /&gt;0 4 4&lt;BR /&gt;0 5 5&lt;BR /&gt;0 6 2&lt;BR /&gt;0 7 7&lt;BR /&gt;0 8 1&lt;BR /&gt;0 9 13&lt;BR /&gt;0 1 10 5&lt;BR /&gt;0 1 56&lt;BR /&gt;0 2 26&lt;BR /&gt;0 3 46&lt;BR /&gt;0 4 46&lt;BR /&gt;0 5 18&lt;BR /&gt;0 6 58&lt;BR /&gt;0 7 8&lt;BR /&gt;0 8 2&lt;BR /&gt;0 9 100&lt;BR /&gt;1 10 5&lt;BR /&gt;;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;*IF START=1 THEN DO THE FOLLOWING PROCESS;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data want;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;set have;&lt;BR /&gt;drop aa1-aa10;&lt;BR /&gt;array a{0:9} aa1-aa10;&lt;BR /&gt;retain aa:;&lt;BR /&gt;pct_60=largest((10-10*60/100+1),of a{*}); &lt;BR /&gt;pct_70=largest((10-10*70/100+1),of a{*}); &lt;BR /&gt;pct_80=largest((10-10*80/100+1),of a{*});&lt;BR /&gt;pct_90=largest((10-10*90/100+1),of a{*});&lt;BR /&gt;a{mod(_n_,10)}=value;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;data want; set want;&lt;BR /&gt;drop pct_25-pct_100 ;&lt;BR /&gt;if value&amp;gt;=pct_90 then ROC_rank=5;&lt;BR /&gt;else if value&amp;gt;=pct_80 then ROC_rank=4;&lt;BR /&gt;else if value&amp;gt;=pct_70 then ROC_rank=3;&lt;BR /&gt;else if value&amp;gt;=pct_60 then ROC_rank=1.5;&lt;BR /&gt;else ROC_rank=0.1;&lt;BR /&gt;run;&lt;/P&gt;</description>
      <pubDate>Sun, 18 Oct 2015 03:05:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Start-a-process-when-start-variable-1/m-p/230455#M268056</guid>
      <dc:creator>hhchenfx</dc:creator>
      <dc:date>2015-10-18T03:05:57Z</dc:date>
    </item>
    <item>
      <title>Re: Start a process when start_variable=1</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Start-a-process-when-start-variable-1/m-p/230458#M268057</link>
      <description>&lt;P&gt;I'm not certain I understand fully. It seems like you want to compare &lt;EM&gt;value&lt;/EM&gt; with the preceeding 10 values and set &lt;EM&gt;ROC_rank&lt;/EM&gt; based on the ranking of &lt;EM&gt;value&lt;/EM&gt; relative to the set of 10. Furthermore, you want output only for cases where &lt;EM&gt;start&lt;/EM&gt;=1. The role of variable &lt;EM&gt;order&lt;/EM&gt; is undefined. This would do that:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
set have;
array a{0:9} _temporary_;
if start and nmiss(of a{*})=0 then do;
    if      value&amp;gt;=largest(1,of a{*}) then ROC_rank=5;
    else if value&amp;gt;=largest(2,of a{*}) then ROC_rank=4;
    else if value&amp;gt;=largest(3,of a{*}) then ROC_rank=3;
    else if value&amp;gt;=largest(4,of a{*}) then ROC_rank=1.5;
    else                                   ROC_rank=0.1;
    output;
    end;
a{mod(_n_,10)}=value;
run;&lt;/CODE&gt;&amp;nbsp;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 18 Oct 2015 03:53:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Start-a-process-when-start-variable-1/m-p/230458#M268057</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2015-10-18T03:53:41Z</dc:date>
    </item>
    <item>
      <title>Re: Start a process when start_variable=1</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Start-a-process-when-start-variable-1/m-p/230462#M268058</link>
      <description>&lt;P&gt;Hi PGStats,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Your code work perfectly in this case. And yes, I only need to output record with start=1.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;However, I did not foresee that it can be done in only 1 step.&lt;/P&gt;
&lt;P&gt;And my code to run when start=1 involve few other steps.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So it is the best for me if I can put the MAIN&amp;nbsp;analysis section within some kind IF as below.&lt;/P&gt;
&lt;P&gt;It will help me alot for other applicaiton as well.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you so much.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;HHC&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;U&gt;&lt;FONT color="#000000"&gt;IF start=1 then do;&lt;/FONT&gt;&lt;/U&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data want;&lt;BR /&gt;set have;&lt;BR /&gt;drop aa1-aa10;&lt;BR /&gt;array a{0:9} aa1-aa10;&lt;BR /&gt;retain aa:;&lt;BR /&gt;pct_60=largest((10-10*60/100+1),of a{*}); &lt;BR /&gt;pct_70=largest((10-10*70/100+1),of a{*}); &lt;BR /&gt;pct_80=largest((10-10*80/100+1),of a{*});&lt;BR /&gt;pct_90=largest((10-10*90/100+1),of a{*});&lt;BR /&gt;a{mod(_n_,10)}=value;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;U&gt;END;&lt;/U&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;data want; set want;&lt;BR /&gt;drop pct_25-pct_100 ;&lt;BR /&gt;if value&amp;gt;=pct_90 then ROC_rank=5;&lt;BR /&gt;else if value&amp;gt;=pct_80 then ROC_rank=4;&lt;BR /&gt;else if value&amp;gt;=pct_70 then ROC_rank=3;&lt;BR /&gt;else if value&amp;gt;=pct_60 then ROC_rank=1.5;&lt;BR /&gt;else ROC_rank=0.1;&lt;BR /&gt;run;&lt;/P&gt;</description>
      <pubDate>Sun, 18 Oct 2015 04:59:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Start-a-process-when-start-variable-1/m-p/230462#M268058</guid>
      <dc:creator>hhchenfx</dc:creator>
      <dc:date>2015-10-18T04:59:50Z</dc:date>
    </item>
  </channel>
</rss>

