<?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: Retain or Lag for a certain amount of observations in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Retain-or-Lag-for-a-certain-amount-of-observations/m-p/392743#M94543</link>
    <description>&lt;P&gt;Works like a charm! Thank you!!&lt;/P&gt;</description>
    <pubDate>Sat, 02 Sep 2017 13:52:05 GMT</pubDate>
    <dc:creator>MarcBoh</dc:creator>
    <dc:date>2017-09-02T13:52:05Z</dc:date>
    <item>
      <title>Retain or Lag for a certain amount of observations</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Retain-or-Lag-for-a-certain-amount-of-observations/m-p/392732#M94537</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;I would like to retain a certain observation&amp;nbsp;in SAS for a certain amount of observations forward.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;If a criteria is met (date=announcement_date) then retain the value for the next 60 observations.&lt;/P&gt;&lt;P&gt;I don't want to write 60 lags but also make it flexible and change the 60 to 30 or whatever.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Best,&lt;BR /&gt;M&lt;/P&gt;</description>
      <pubDate>Sat, 02 Sep 2017 12:45:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Retain-or-Lag-for-a-certain-amount-of-observations/m-p/392732#M94537</guid>
      <dc:creator>MarcBoh</dc:creator>
      <dc:date>2017-09-02T12:45:32Z</dc:date>
    </item>
    <item>
      <title>Re: Retain or Lag for a certain amount of observations</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Retain-or-Lag-for-a-certain-amount-of-observations/m-p/392736#M94540</link>
      <description>&lt;P&gt;After you've initially found a record that met your criterion and are retaining it for the next 60 observations, do you need to continue to check that criterion on the subsequent records? In short, tell us more about what you are trying to accomplish.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Art, CEO, AnalystFinder.com&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 02 Sep 2017 13:31:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Retain-or-Lag-for-a-certain-amount-of-observations/m-p/392736#M94540</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2017-09-02T13:31:17Z</dc:date>
    </item>
    <item>
      <title>Re: Retain or Lag for a certain amount of observations</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Retain-or-Lag-for-a-certain-amount-of-observations/m-p/392737#M94541</link>
      <description>&lt;P&gt;Thanks for the reply.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to establish an event study and one data set as stocks, dates and prices. the second one has stocks and announcement dates.&lt;/P&gt;&lt;P&gt;So basically always when date=announcement_date I want to fill in an additional (dummy variable) with just ones into the next 60 rows.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 02 Sep 2017 13:33:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Retain-or-Lag-for-a-certain-amount-of-observations/m-p/392737#M94541</guid>
      <dc:creator>MarcBoh</dc:creator>
      <dc:date>2017-09-02T13:33:03Z</dc:date>
    </item>
    <item>
      <title>Re: Retain or Lag for a certain amount of observations</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Retain-or-Lag-for-a-certain-amount-of-observations/m-p/392742#M94542</link>
      <description>&lt;P&gt;I set the iterations to 6 in the following example, but that could be changed to 30, 60 or whatever you want:&lt;/P&gt;
&lt;PRE&gt;data want (drop=counter);
  set have;
  retain dummy;
  if missing(counter) then do;
    if date eq announcement_date then do;
      dummy=x;
      counter=0;
    end;
  end;
  else do;
    counter+1;
    if date eq announcement_date then do;
      dummy=x;
      counter=0;
    end;
    if counter eq 6 then do;
      call missing(counter);
      call missing(dummy);
    end;
  end;
run;
&lt;/PRE&gt;
&lt;P&gt;Art, CEO, AnalystFinder.com&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 02 Sep 2017 13:47:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Retain-or-Lag-for-a-certain-amount-of-observations/m-p/392742#M94542</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2017-09-02T13:47:07Z</dc:date>
    </item>
    <item>
      <title>Re: Retain or Lag for a certain amount of observations</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Retain-or-Lag-for-a-certain-amount-of-observations/m-p/392743#M94543</link>
      <description>&lt;P&gt;Works like a charm! Thank you!!&lt;/P&gt;</description>
      <pubDate>Sat, 02 Sep 2017 13:52:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Retain-or-Lag-for-a-certain-amount-of-observations/m-p/392743#M94543</guid>
      <dc:creator>MarcBoh</dc:creator>
      <dc:date>2017-09-02T13:52:05Z</dc:date>
    </item>
  </channel>
</rss>

