<?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 How do I subset based on the cumulative change of a variable from its previously selected value? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-subset-based-on-the-cumulative-change-of-a-variable/m-p/453083#M114430</link>
    <description>&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am new to SAS and I find myself needing your help for the first time, so apologies in advance for any mistakes.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a dataset containing the variables 'Price' and 'Time' for every transaction executed in a given period for a stock.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I need to subset this dataset by only selecting the observations for which the cumulative price change is greater than a&amp;nbsp;constant amount 'c'.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So that:&lt;/P&gt;&lt;P&gt;&amp;gt;the first observation of the new dataset is the same as the original&lt;/P&gt;&lt;P&gt;&amp;gt;then, we select only observations for which the absolute difference between Price(i) and the &lt;U&gt;previously selected Price(i)*&lt;/U&gt; is greater than or equal to a constant c, say 0.25.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am using SAS University Edition.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 11 Apr 2018 06:48:40 GMT</pubDate>
    <dc:creator>AntCli</dc:creator>
    <dc:date>2018-04-11T06:48:40Z</dc:date>
    <item>
      <title>How do I subset based on the cumulative change of a variable from its previously selected value?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-subset-based-on-the-cumulative-change-of-a-variable/m-p/453083#M114430</link>
      <description>&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am new to SAS and I find myself needing your help for the first time, so apologies in advance for any mistakes.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a dataset containing the variables 'Price' and 'Time' for every transaction executed in a given period for a stock.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I need to subset this dataset by only selecting the observations for which the cumulative price change is greater than a&amp;nbsp;constant amount 'c'.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So that:&lt;/P&gt;&lt;P&gt;&amp;gt;the first observation of the new dataset is the same as the original&lt;/P&gt;&lt;P&gt;&amp;gt;then, we select only observations for which the absolute difference between Price(i) and the &lt;U&gt;previously selected Price(i)*&lt;/U&gt; is greater than or equal to a constant c, say 0.25.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am using SAS University Edition.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 11 Apr 2018 06:48:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-subset-based-on-the-cumulative-change-of-a-variable/m-p/453083#M114430</guid>
      <dc:creator>AntCli</dc:creator>
      <dc:date>2018-04-11T06:48:40Z</dc:date>
    </item>
    <item>
      <title>Re: How do I subset based on the cumulative change of a variable from its previously selected value?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-subset-based-on-the-cumulative-change-of-a-variable/m-p/453087#M114434</link>
      <description>&lt;P&gt;Try next code:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let c = 0.25;
data want;
  set have;
        retain prev_selected_price;

        if _N_=1 then do; 
           output;
           prev_selected_price = price;
        end;
        else if abs(price - prev_selected_price) ge  &amp;amp;c 
         then do;
               output;
               prev_selected_price = price;  /* ??? */
        end;
run;
        &lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 11 Apr 2018 07:16:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-subset-based-on-the-cumulative-change-of-a-variable/m-p/453087#M114434</guid>
      <dc:creator>Shmuel</dc:creator>
      <dc:date>2018-04-11T07:16:43Z</dc:date>
    </item>
  </channel>
</rss>

