<?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: Loop event time list and calculate mean in another data set according to the event time interval in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Loop-event-time-list-and-calculate-mean-in-another-data-set/m-p/450545#M283725</link>
    <description>&lt;P&gt;Post example test data in the form of a datastep.&amp;nbsp; You can follow the post at:&lt;/P&gt;
&lt;P&gt;&lt;A href="https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-data-AKA-generate/ta-p/258712" target="_blank"&gt;https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-data-AKA-generate/ta-p/258712&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Then show what the output should be from that test data.&amp;nbsp; It looks like your doing a simple sum() and count() based on a group of date between two groups.&amp;nbsp; It may therefore be easier to do:&lt;/P&gt;
&lt;PRE class=" language-sas"&gt;&lt;CODE class="  language-sas"&gt;&lt;SPAN class="token procnames"&gt;data&lt;/SPAN&gt; meanvol&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
&lt;SPAN class="token keyword"&gt;  set&lt;/SPAN&gt; work&lt;SPAN class="token punctuation"&gt;.&lt;/SPAN&gt;forms41&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
&lt;SPAN class="token statement"&gt;  by&lt;/SPAN&gt; cusip&lt;SPAN class="token punctuation"&gt;;&lt;BR /&gt;&lt;/SPAN&gt;  retain total n; 
&lt;SPAN class="token keyword"&gt;  if&lt;/SPAN&gt; &lt;SPAN class="token function"&gt;first&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;.&lt;/SPAN&gt;cusip &lt;SPAN class="token keyword"&gt;then&lt;/SPAN&gt; call &lt;SPAN class="token function"&gt;missing&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;total&lt;SPAN class="token punctuation"&gt;,&lt;/SPAN&gt;&lt;SPAN class="token function"&gt;n&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
&lt;SPAN class="token keyword"&gt;  if&lt;/SPAN&gt; &lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;secd&lt;SPAN class="token operator"&gt;-&lt;/SPAN&gt;&lt;SPAN class="token number"&gt;45&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt; &lt;SPAN class="token operator"&gt;&amp;lt;=&lt;/SPAN&gt; &lt;SPAN class="token function"&gt;date&lt;/SPAN&gt; &lt;SPAN class="token operator"&gt;&amp;lt;=&lt;/SPAN&gt; &lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;secd&lt;SPAN class="token operator"&gt;+&lt;/SPAN&gt;&lt;SPAN class="token number"&gt;45&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt; &lt;SPAN class="token keyword"&gt;then&lt;/SPAN&gt; do&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
    total&lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt;&lt;SPAN class="token function"&gt;sum&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;total&lt;SPAN class="token punctuation"&gt;,&lt;/SPAN&gt;vol&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt; 
&lt;SPAN class="token function"&gt;    n&lt;/SPAN&gt;&lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt;&lt;SPAN class="token function"&gt;sum&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;&lt;SPAN class="token function"&gt;n&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;,&lt;/SPAN&gt;&lt;SPAN class="token number"&gt;1&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt; &lt;BR /&gt;  end&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
  if last.cusip then do;&lt;BR /&gt;    avgvoldsf&lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt;total&lt;SPAN class="token operator"&gt;/&lt;/SPAN&gt;&lt;SPAN class="token function"&gt;n&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;BR /&gt;&lt;/SPAN&gt;    output;&lt;BR /&gt;  end;
&lt;SPAN class="token procnames"&gt;run&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Tue, 03 Apr 2018 08:32:34 GMT</pubDate>
    <dc:creator>RW9</dc:creator>
    <dc:date>2018-04-03T08:32:34Z</dc:date>
    <item>
      <title>Loop event time list and calculate mean in another data set according to the event time interval.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Loop-event-time-list-and-calculate-mean-in-another-data-set/m-p/450529#M283721</link>
      <description>&lt;P&gt;I have a data set with event timestamp and cusip for the stock and I want to calculate the mean volume around the timestamp using crsp.dsf file.&amp;nbsp; I am thinking of loop every row in the first data set and use the timestamp in each row to match and calculate the mean volume in crsp for that company for a fixed time interval.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But it seems that do loop cant work with two data sets.&amp;nbsp; Anyone have any ideas?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 03 Apr 2018 06:58:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Loop-event-time-list-and-calculate-mean-in-another-data-set/m-p/450529#M283721</guid>
      <dc:creator>Sasadomo</dc:creator>
      <dc:date>2018-04-03T06:58:06Z</dc:date>
    </item>
    <item>
      <title>Re: Loop event time list and calculate mean in another data set according to the event time interval. [how to improve your question]</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Loop-event-time-list-and-calculate-mean-in-another-data-set/m-p/450530#M283722</link>
      <description>&lt;P&gt;Hello &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/202368"&gt;@Sasadomo&lt;/a&gt;,&lt;/P&gt;&lt;BR /&gt; &lt;P&gt;Your question requires more details before experts can help.&amp;nbsp;Can you revise your question to include more information?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Review this checklist:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;Specify a meaningful subject line for your topic.&amp;nbsp; Avoid generic subjects like "need help," "SAS query," or "urgent."&lt;/LI&gt;
&lt;LI&gt;When appropriate, provide sample data in text or DATA step format.&amp;nbsp; See &lt;A href="https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-data-AKA-generate/ta-p/258712" target="_blank"&gt;this article for one method&lt;/A&gt;&amp;nbsp;you can use.&lt;/LI&gt;
&lt;LI&gt;If you're encountering an error in SAS, include the SAS log or a screenshot of the error condition.&amp;nbsp;Use the&amp;nbsp;&lt;STRONG&gt;Photos&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;button to include the image in your message.&lt;BR /&gt;&lt;SPAN class="lia-inline-image-display-wrapper lia-image-align-inline" style="width: 279px;"&gt;&lt;IMG src="https://kntur85557.i.lithium.com/t5/image/serverpage/image-id/16608i91A52F817EAC9A69/image-dimensions/279x150?v=1.0" width="279" height="150" alt="use_buttons.png" title="use_buttons.png" /&gt;&lt;/SPAN&gt;&lt;/LI&gt;
&lt;LI&gt;It also helps to include an example (table or picture) of the result that you're trying to achieve.&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;To edit your original message, select the "blue gear" icon at the top of the message and select&amp;nbsp;&lt;STRONG&gt;Edit Message&lt;/STRONG&gt;.&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&lt;/STRONG&gt;From there you can adjust the title and add more details to the body of the message.&amp;nbsp; Or, simply reply to this message with any additional information you can supply.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="lia-inline-image-display-wrapper lia-image-align-inline" style="width: 229px;"&gt;&lt;IMG src="https://kntur85557.i.lithium.com/t5/image/serverpage/image-id/16605iAC020BC79315B045/image-size/large?v=1.0&amp;amp;px=600" alt="edit_post.png" title="edit_post.png" /&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;SAS experts are eager to help -- help&amp;nbsp;&lt;EM&gt;them&lt;/EM&gt; by providing as much detail as you can.&lt;/P&gt; &lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-style:italic;font-size:smaller;"&gt;This prewritten response was triggered for you by fellow SAS Support Communities member &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/31304"&gt;@PeterClemmensen&lt;/a&gt;&lt;/SPAN&gt;&lt;/P&gt;.</description>
      <pubDate>Tue, 03 Apr 2018 06:58:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Loop-event-time-list-and-calculate-mean-in-another-data-set/m-p/450530#M283722</guid>
      <dc:creator>Community_Guide</dc:creator>
      <dc:date>2018-04-03T06:58:35Z</dc:date>
    </item>
    <item>
      <title>Re: Loop event time list and calculate mean in another data set according to the event time interval</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Loop-event-time-list-and-calculate-mean-in-another-data-set/m-p/450531#M283723</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In the second level of the loop, I would like to perform the following loop for every event date stamp:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data meanvol;
do until (last.cusip); 
	set work.forms41;
	by cusip; 
	if first.cusip then call missing(total,n);
	if (secd-45) &amp;lt;= date &amp;lt;= (secd+45) then 
	do;
	total=sum(total,vol); 
	n=sum(n,1); 
	end;
end;
avgvoldsf=total/n;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 03 Apr 2018 07:20:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Loop-event-time-list-and-calculate-mean-in-another-data-set/m-p/450531#M283723</guid>
      <dc:creator>Sasadomo</dc:creator>
      <dc:date>2018-04-03T07:20:17Z</dc:date>
    </item>
    <item>
      <title>Re: Loop event time list and calculate mean in another data set according to the event time interval</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Loop-event-time-list-and-calculate-mean-in-another-data-set/m-p/450532#M283724</link>
      <description>where secd is the date part of the event timestamp contained in work.forms41</description>
      <pubDate>Tue, 03 Apr 2018 07:21:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Loop-event-time-list-and-calculate-mean-in-another-data-set/m-p/450532#M283724</guid>
      <dc:creator>Sasadomo</dc:creator>
      <dc:date>2018-04-03T07:21:46Z</dc:date>
    </item>
    <item>
      <title>Re: Loop event time list and calculate mean in another data set according to the event time interval</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Loop-event-time-list-and-calculate-mean-in-another-data-set/m-p/450545#M283725</link>
      <description>&lt;P&gt;Post example test data in the form of a datastep.&amp;nbsp; You can follow the post at:&lt;/P&gt;
&lt;P&gt;&lt;A href="https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-data-AKA-generate/ta-p/258712" target="_blank"&gt;https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-data-AKA-generate/ta-p/258712&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Then show what the output should be from that test data.&amp;nbsp; It looks like your doing a simple sum() and count() based on a group of date between two groups.&amp;nbsp; It may therefore be easier to do:&lt;/P&gt;
&lt;PRE class=" language-sas"&gt;&lt;CODE class="  language-sas"&gt;&lt;SPAN class="token procnames"&gt;data&lt;/SPAN&gt; meanvol&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
&lt;SPAN class="token keyword"&gt;  set&lt;/SPAN&gt; work&lt;SPAN class="token punctuation"&gt;.&lt;/SPAN&gt;forms41&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
&lt;SPAN class="token statement"&gt;  by&lt;/SPAN&gt; cusip&lt;SPAN class="token punctuation"&gt;;&lt;BR /&gt;&lt;/SPAN&gt;  retain total n; 
&lt;SPAN class="token keyword"&gt;  if&lt;/SPAN&gt; &lt;SPAN class="token function"&gt;first&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;.&lt;/SPAN&gt;cusip &lt;SPAN class="token keyword"&gt;then&lt;/SPAN&gt; call &lt;SPAN class="token function"&gt;missing&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;total&lt;SPAN class="token punctuation"&gt;,&lt;/SPAN&gt;&lt;SPAN class="token function"&gt;n&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
&lt;SPAN class="token keyword"&gt;  if&lt;/SPAN&gt; &lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;secd&lt;SPAN class="token operator"&gt;-&lt;/SPAN&gt;&lt;SPAN class="token number"&gt;45&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt; &lt;SPAN class="token operator"&gt;&amp;lt;=&lt;/SPAN&gt; &lt;SPAN class="token function"&gt;date&lt;/SPAN&gt; &lt;SPAN class="token operator"&gt;&amp;lt;=&lt;/SPAN&gt; &lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;secd&lt;SPAN class="token operator"&gt;+&lt;/SPAN&gt;&lt;SPAN class="token number"&gt;45&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt; &lt;SPAN class="token keyword"&gt;then&lt;/SPAN&gt; do&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
    total&lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt;&lt;SPAN class="token function"&gt;sum&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;total&lt;SPAN class="token punctuation"&gt;,&lt;/SPAN&gt;vol&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt; 
&lt;SPAN class="token function"&gt;    n&lt;/SPAN&gt;&lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt;&lt;SPAN class="token function"&gt;sum&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;&lt;SPAN class="token function"&gt;n&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;,&lt;/SPAN&gt;&lt;SPAN class="token number"&gt;1&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt; &lt;BR /&gt;  end&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
  if last.cusip then do;&lt;BR /&gt;    avgvoldsf&lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt;total&lt;SPAN class="token operator"&gt;/&lt;/SPAN&gt;&lt;SPAN class="token function"&gt;n&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;BR /&gt;&lt;/SPAN&gt;    output;&lt;BR /&gt;  end;
&lt;SPAN class="token procnames"&gt;run&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 03 Apr 2018 08:32:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Loop-event-time-list-and-calculate-mean-in-another-data-set/m-p/450545#M283725</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2018-04-03T08:32:34Z</dc:date>
    </item>
    <item>
      <title>Re: Loop event time list and calculate mean in another data set according to the event time interval</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Loop-event-time-list-and-calculate-mean-in-another-data-set/m-p/450783#M283726</link>
      <description>&lt;P&gt;Show us what the 2 datasets look like.&amp;nbsp; Does your crsp dsf file have 8-digit CUSIP? (stock specific, not company specific), or does it use&amp;nbsp; permno as an id?&amp;nbsp; What are the relevant variable names in BOTH of the data sets of interest?&amp;nbsp; Help us help you.&lt;/P&gt;</description>
      <pubDate>Tue, 03 Apr 2018 18:18:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Loop-event-time-list-and-calculate-mean-in-another-data-set/m-p/450783#M283726</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2018-04-03T18:18:00Z</dc:date>
    </item>
    <item>
      <title>Re: Loop event time list and calculate mean in another data set according to the event time interval</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Loop-event-time-list-and-calculate-mean-in-another-data-set/m-p/450835#M283727</link>
      <description>&lt;P&gt;Thank you for your reply.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Yes I have the 8-digit cusip in both data sets. The following is the what the data sets looks like: This is the first data set with the event time&lt;span class="lia-inline-image-display-wrapper lia-image-align-center" image-alt="Image_20180403151751.png" style="width: 600px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/19587i6A643B6DCD4B0345/image-size/large?v=v2&amp;amp;px=999" role="button" title="Image_20180403151751.png" alt="Image_20180403151751.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;And this is the second data set with the the daily volume.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-center" image-alt="Image_20180403151847.png" style="width: 600px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/19586i9050893B3F49FE20/image-size/large?v=v2&amp;amp;px=999" role="button" title="Image_20180403151847.png" alt="Image_20180403151847.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;What I attempted to do is loop every row in the first data set and for each row, match company according&amp;nbsp; to the cusip in the second data set and calculate 90 days (45 days before and 45 days after ) mean for this&amp;nbsp;&lt;SPAN&gt;company&amp;nbsp;around the event day.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 03 Apr 2018 19:45:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Loop-event-time-list-and-calculate-mean-in-another-data-set/m-p/450835#M283727</guid>
      <dc:creator>Sasadomo</dc:creator>
      <dc:date>2018-04-03T19:45:58Z</dc:date>
    </item>
    <item>
      <title>Re: Loop event time list and calculate mean in another data set according to the event time interval</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Loop-event-time-list-and-calculate-mean-in-another-data-set/m-p/450838#M283728</link>
      <description>&lt;P&gt;May I ask why it would be easier to use the code provided? I think they will produce the same result.&lt;/P&gt;</description>
      <pubDate>Tue, 03 Apr 2018 19:48:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Loop-event-time-list-and-calculate-mean-in-another-data-set/m-p/450838#M283728</guid>
      <dc:creator>Sasadomo</dc:creator>
      <dc:date>2018-04-03T19:48:25Z</dc:date>
    </item>
    <item>
      <title>Re: Loop event time list and calculate mean in another data set according to the event time interval</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Loop-event-time-list-and-calculate-mean-in-another-data-set/m-p/450897#M283729</link>
      <description>&lt;P&gt;For example, for first row in the first data set, there's a event on 2002/06/06 at 10:28:44 for company 00036110. I would like to match company&amp;nbsp;&lt;SPAN&gt;00036110 in the second data set and find find the 90 days mean for vol(in the second data set) around event date&amp;nbsp;2002/06/06. And repeat this process for every row in the first data set.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 03 Apr 2018 21:26:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Loop-event-time-list-and-calculate-mean-in-another-data-set/m-p/450897#M283729</guid>
      <dc:creator>Sasadomo</dc:creator>
      <dc:date>2018-04-03T21:26:51Z</dc:date>
    </item>
    <item>
      <title>Re: Loop event time list and calculate mean in another data set according to the event time interval</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Loop-event-time-list-and-calculate-mean-in-another-data-set/m-p/450898#M283730</link>
      <description>&lt;P&gt;Your crsp.dsf dataset is almost certainly sorted by permno, not by cusip, so you either have to sort it by cusip/date (expensive given the size of the crsp.dsf dataset), or sort your form41 data set by permno.&amp;nbsp; But that dataset&amp;nbsp;probably doesn't have permno, correct?&amp;nbsp; You might want to get permno's for your form41 dataset.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also, before I suggest an approach, I see you have multiple events per cusip, and those event are often less the 45 days from each other.&amp;nbsp; So do you want 90 records for EACH event?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Or if a sequence of events have no gaps larger the 45 days, do you want a single group of records starting 45 days before the earliest event in the sequence through 45 days after the latest event in the sequence.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Finally, are your CUSIPs in FORM41 the latest cusip for a given stock? Or are they merely contemporaneous with the SECD data value?&amp;nbsp; It's possible that a company&amp;nbsp;has merged or split since SECD, in which case CUSIPs change, but CRSP continues the permno for the surviving company.&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;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 03 Apr 2018 21:27:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Loop-event-time-list-and-calculate-mean-in-another-data-set/m-p/450898#M283730</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2018-04-03T21:27:22Z</dc:date>
    </item>
    <item>
      <title>Re: Loop event time list and calculate mean in another data set according to the event time interval</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Loop-event-time-list-and-calculate-mean-in-another-data-set/m-p/450935#M283731</link>
      <description>- Yes crsp.dsf is currently ordered by permno and I will order it by cusip if I am using cusip.&lt;BR /&gt;&lt;BR /&gt;-For accuracy, I would prefer 90 records for each event (and the event dates are pretty disperse so making 15 days groups might be unnecessary)&lt;BR /&gt;&lt;BR /&gt;-they are the latest cusip form the master table. I thought of using gvkey which is unique but it shouldn't be big issue if there's change or split as I cut off the events that are not consistent of the first filling date and last filling date.&lt;BR /&gt;&lt;BR /&gt;-</description>
      <pubDate>Wed, 04 Apr 2018 03:08:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Loop-event-time-list-and-calculate-mean-in-another-data-set/m-p/450935#M283731</guid>
      <dc:creator>Sasadomo</dc:creator>
      <dc:date>2018-04-04T03:08:44Z</dc:date>
    </item>
  </channel>
</rss>

