<?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: Expanding the data set for each event day in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Expanding-the-data-set-for-each-event-day/m-p/877894#M346827</link>
    <description>&lt;P&gt;Thanks&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13884"&gt;@ballardw&lt;/a&gt;&amp;nbsp;for pointing out where I missed what the OP asked for.&lt;/P&gt;
&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/1906"&gt;@finans_sas&lt;/a&gt;&amp;nbsp; Below should work.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
  set have(keep=secid obs_date event rename=(secid=_secid obs_date=_obs_date));
  by _secid _obs_date;
  if event=1;

  day_count=0;

  do _i=_n_ to _nobs;
    set have point=_i  nobs=_nobs;
    if _secid ne secid then leave;

/*    if day_count&amp;gt;179 then leave;*/

    if intck('month',_obs_date,obs_date)&amp;gt;=6 then leave;

    output;
    day_count+1;
  end;
  drop _:;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Sun, 28 May 2023 03:54:21 GMT</pubDate>
    <dc:creator>Patrick</dc:creator>
    <dc:date>2023-05-28T03:54:21Z</dc:date>
    <item>
      <title>Expanding the data set for each event day</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Expanding-the-data-set-for-each-event-day/m-p/877787#M346767</link>
      <description>&lt;P&gt;Hello Everyone:&lt;/P&gt;
&lt;P&gt;I have a dataset similar to the one that I provided below:&lt;/P&gt;
&lt;TABLE width="196"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD width="68"&gt;obs_date&lt;/TD&gt;
&lt;TD width="64"&gt;event&lt;/TD&gt;
&lt;TD width="64"&gt;value&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;1/1/2020&lt;/TD&gt;
&lt;TD&gt;0&lt;/TD&gt;
&lt;TD&gt;0.003918&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;1/2/2020&lt;/TD&gt;
&lt;TD&gt;0&lt;/TD&gt;
&lt;TD&gt;0.294439&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;1/4/2020&lt;/TD&gt;
&lt;TD&gt;1&lt;/TD&gt;
&lt;TD&gt;0.048467&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;1/5/2020&lt;/TD&gt;
&lt;TD&gt;0&lt;/TD&gt;
&lt;TD&gt;0.718177&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;1/6/2020&lt;/TD&gt;
&lt;TD&gt;0&lt;/TD&gt;
&lt;TD&gt;0.001364&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;1/7/2020&lt;/TD&gt;
&lt;TD&gt;0&lt;/TD&gt;
&lt;TD&gt;0.440972&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;1/8/2020&lt;/TD&gt;
&lt;TD&gt;0&lt;/TD&gt;
&lt;TD&gt;0.559622&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;1/9/2020&lt;/TD&gt;
&lt;TD&gt;0&lt;/TD&gt;
&lt;TD&gt;0.821105&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;1/10/2020&lt;/TD&gt;
&lt;TD&gt;1&lt;/TD&gt;
&lt;TD&gt;0.332539&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;1/11/2020&lt;/TD&gt;
&lt;TD&gt;0&lt;/TD&gt;
&lt;TD&gt;0.289809&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;1/12/2020&lt;/TD&gt;
&lt;TD&gt;0&lt;/TD&gt;
&lt;TD&gt;0.911323&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;1/18/2020&lt;/TD&gt;
&lt;TD&gt;0&lt;/TD&gt;
&lt;TD&gt;0.896737&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;1/19/2020&lt;/TD&gt;
&lt;TD&gt;0&lt;/TD&gt;
&lt;TD&gt;0.333354&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;1/20/2020&lt;/TD&gt;
&lt;TD&gt;0&lt;/TD&gt;
&lt;TD&gt;0.19605&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;1/21/2020&lt;/TD&gt;
&lt;TD&gt;0&lt;/TD&gt;
&lt;TD&gt;0.606891&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;1/22/2020&lt;/TD&gt;
&lt;TD&gt;1&lt;/TD&gt;
&lt;TD&gt;0.439834&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;1/23/2020&lt;/TD&gt;
&lt;TD&gt;0&lt;/TD&gt;
&lt;TD&gt;0.896842&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;1/24/2020&lt;/TD&gt;
&lt;TD&gt;0&lt;/TD&gt;
&lt;TD&gt;0.147459&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;.....&lt;/P&gt;
&lt;P&gt;My objective is to retain the next 180 observations of "value" every time event=1 (days do not have to be consecutive). At the end, I would like to have the following dataset:&lt;/P&gt;
&lt;TABLE width="271"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD width="88.4833px" height="30px"&gt;obs_date&lt;/TD&gt;
&lt;TD width="85.6833px" height="30px"&gt;eventday&lt;/TD&gt;
&lt;TD width="81.3px" height="30px"&gt;value&lt;/TD&gt;
&lt;TD width="84.5px" height="30px"&gt;day_count&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="88.4833px" height="30px"&gt;1/4/2020&lt;/TD&gt;
&lt;TD width="85.6833px" height="30px"&gt;1/4/2020&lt;/TD&gt;
&lt;TD width="81.3px" height="30px"&gt;0.048467&lt;/TD&gt;
&lt;TD width="84.5px" height="30px"&gt;0&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="88.4833px" height="30px"&gt;1/5/2020&lt;/TD&gt;
&lt;TD width="85.6833px" height="30px"&gt;1/4/2020&lt;/TD&gt;
&lt;TD width="81.3px" height="30px"&gt;0.718177&lt;/TD&gt;
&lt;TD width="84.5px" height="30px"&gt;1&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="88.4833px" height="30px"&gt;1/6/2020&lt;/TD&gt;
&lt;TD width="85.6833px" height="30px"&gt;1/4/2020&lt;/TD&gt;
&lt;TD width="81.3px" height="30px"&gt;0.001364&lt;/TD&gt;
&lt;TD width="84.5px" height="30px"&gt;2&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="88.4833px" height="30px"&gt;1/7/2020&lt;/TD&gt;
&lt;TD width="85.6833px" height="30px"&gt;1/4/2020&lt;/TD&gt;
&lt;TD width="81.3px" height="30px"&gt;0.440972&lt;/TD&gt;
&lt;TD width="84.5px" height="30px"&gt;3&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="88.4833px" height="30px"&gt;1/8/2020&lt;/TD&gt;
&lt;TD width="85.6833px" height="30px"&gt;1/4/2020&lt;/TD&gt;
&lt;TD width="81.3px" height="30px"&gt;0.559622&lt;/TD&gt;
&lt;TD width="84.5px" height="30px"&gt;4&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="88.4833px" height="30px"&gt;1/9/2020&lt;/TD&gt;
&lt;TD width="85.6833px" height="30px"&gt;1/4/2020&lt;/TD&gt;
&lt;TD width="81.3px" height="30px"&gt;0.821105&lt;/TD&gt;
&lt;TD width="84.5px" height="30px"&gt;5&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="88.4833px" height="30px"&gt;1/10/2020&lt;/TD&gt;
&lt;TD width="85.6833px" height="30px"&gt;1/4/2020&lt;/TD&gt;
&lt;TD width="81.3px" height="30px"&gt;0.332539&lt;/TD&gt;
&lt;TD width="84.5px" height="30px"&gt;6&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="88.4833px" height="30px"&gt;1/11/2020&lt;/TD&gt;
&lt;TD width="85.6833px" height="30px"&gt;1/4/2020&lt;/TD&gt;
&lt;TD width="81.3px" height="30px"&gt;0.289809&lt;/TD&gt;
&lt;TD width="84.5px" height="30px"&gt;7&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="88.4833px" height="30px"&gt;1/12/2020&lt;/TD&gt;
&lt;TD width="85.6833px" height="30px"&gt;1/4/2020&lt;/TD&gt;
&lt;TD width="81.3px" height="30px"&gt;0.911323&lt;/TD&gt;
&lt;TD width="84.5px" height="30px"&gt;8&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="88.4833px" height="30px"&gt;1/18/2020&lt;/TD&gt;
&lt;TD width="85.6833px" height="30px"&gt;1/4/2020&lt;/TD&gt;
&lt;TD width="81.3px" height="30px"&gt;0.896737&lt;/TD&gt;
&lt;TD width="84.5px" height="30px"&gt;9&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="88.4833px" height="30px"&gt;1/19/2020&lt;/TD&gt;
&lt;TD width="85.6833px" height="30px"&gt;1/4/2020&lt;/TD&gt;
&lt;TD width="81.3px" height="30px"&gt;0.333354&lt;/TD&gt;
&lt;TD width="84.5px" height="30px"&gt;10&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="88.4833px" height="30px"&gt;…&lt;/TD&gt;
&lt;TD width="85.6833px" height="30px"&gt;1/4/2020&lt;/TD&gt;
&lt;TD width="81.3px" height="30px"&gt;....&lt;/TD&gt;
&lt;TD width="84.5px" height="30px"&gt;…&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="88.4833px" height="30px"&gt;…&lt;/TD&gt;
&lt;TD width="85.6833px" height="30px"&gt;1/4/2020&lt;/TD&gt;
&lt;TD width="81.3px" height="30px"&gt;....&lt;/TD&gt;
&lt;TD width="84.5px" height="30px"&gt;180&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="88.4833px" height="30px"&gt;1/10/2020&lt;/TD&gt;
&lt;TD width="85.6833px" height="30px"&gt;1/10/2020&lt;/TD&gt;
&lt;TD width="81.3px" height="30px"&gt;0.332539&lt;/TD&gt;
&lt;TD width="84.5px" height="30px"&gt;0&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="88.4833px" height="30px"&gt;1/11/2020&lt;/TD&gt;
&lt;TD width="85.6833px" height="30px"&gt;1/10/2020&lt;/TD&gt;
&lt;TD width="81.3px" height="30px"&gt;0.289809&lt;/TD&gt;
&lt;TD width="84.5px" height="30px"&gt;1&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="88.4833px" height="30px"&gt;1/12/2020&lt;/TD&gt;
&lt;TD width="85.6833px" height="30px"&gt;1/10/2020&lt;/TD&gt;
&lt;TD width="81.3px" height="30px"&gt;0.911323&lt;/TD&gt;
&lt;TD width="84.5px" height="30px"&gt;2&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="88.4833px" height="30px"&gt;1/18/2020&lt;/TD&gt;
&lt;TD width="85.6833px" height="30px"&gt;1/10/2020&lt;/TD&gt;
&lt;TD width="81.3px" height="30px"&gt;0.896737&lt;/TD&gt;
&lt;TD width="84.5px" height="30px"&gt;3&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="88.4833px" height="30px"&gt;1/19/2020&lt;/TD&gt;
&lt;TD width="85.6833px" height="30px"&gt;1/10/2020&lt;/TD&gt;
&lt;TD width="81.3px" height="30px"&gt;0.333354&lt;/TD&gt;
&lt;TD width="84.5px" height="30px"&gt;4&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="88.4833px" height="30px"&gt;1/20/2020&lt;/TD&gt;
&lt;TD width="85.6833px" height="30px"&gt;1/10/2020&lt;/TD&gt;
&lt;TD width="81.3px" height="30px"&gt;0.19605&lt;/TD&gt;
&lt;TD width="84.5px" height="30px"&gt;5&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="88.4833px" height="30px"&gt;1/21/2020&lt;/TD&gt;
&lt;TD width="85.6833px" height="30px"&gt;1/10/2020&lt;/TD&gt;
&lt;TD width="81.3px" height="30px"&gt;0.606891&lt;/TD&gt;
&lt;TD width="84.5px" height="30px"&gt;6&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="88.4833px" height="30px"&gt;1/22/2020&lt;/TD&gt;
&lt;TD width="85.6833px" height="30px"&gt;1/10/2020&lt;/TD&gt;
&lt;TD width="81.3px" height="30px"&gt;0.439834&lt;/TD&gt;
&lt;TD width="84.5px" height="30px"&gt;7&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="88.4833px" height="30px"&gt;1/23/2020&lt;/TD&gt;
&lt;TD width="85.6833px" height="30px"&gt;1/10/2020&lt;/TD&gt;
&lt;TD width="81.3px" height="30px"&gt;0.896842&lt;/TD&gt;
&lt;TD width="84.5px" height="30px"&gt;8&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="88.4833px" height="30px"&gt;1/24/2020&lt;/TD&gt;
&lt;TD width="85.6833px" height="30px"&gt;1/10/2020&lt;/TD&gt;
&lt;TD width="81.3px" height="30px"&gt;0.147459&lt;/TD&gt;
&lt;TD width="84.5px" height="30px"&gt;9&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="88.4833px" height="30px"&gt;1/25/2020&lt;/TD&gt;
&lt;TD width="85.6833px" height="30px"&gt;1/10/2020&lt;/TD&gt;
&lt;TD width="81.3px" height="30px"&gt;0.923238&lt;/TD&gt;
&lt;TD width="84.5px" height="30px"&gt;10&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="88.4833px" height="30px"&gt;…&lt;/TD&gt;
&lt;TD width="85.6833px" height="30px"&gt;1/10/2020&lt;/TD&gt;
&lt;TD width="81.3px" height="30px"&gt;...&lt;/TD&gt;
&lt;TD width="84.5px" height="30px"&gt;…&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="88.4833px" height="30px"&gt;…&lt;/TD&gt;
&lt;TD width="85.6833px" height="30px"&gt;1/10/2020&lt;/TD&gt;
&lt;TD width="81.3px" height="30px"&gt;...&lt;/TD&gt;
&lt;TD width="84.5px" height="30px"&gt;180&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I could not figure out how to perform this data step. I would love to get your suggestions on it. Thank you so much for your help in advance.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 26 May 2023 20:52:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Expanding-the-data-set-for-each-event-day/m-p/877787#M346767</guid>
      <dc:creator>finans_sas</dc:creator>
      <dc:date>2023-05-26T20:52:33Z</dc:date>
    </item>
    <item>
      <title>Re: Expanding the data set for each event day</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Expanding-the-data-set-for-each-event-day/m-p/877794#M346770</link>
      <description>&lt;P&gt;One way maybe. First step is to add something that can be used to determine observation number difference.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please note use of a data step to provide example data. Please do so in the future.&lt;/P&gt;
&lt;PRE&gt;data have;
   input obs_date :mmddyy10. 	event 	value;
   format obs_date mmddyy10.;
datalines;
1/1/2020 	0 	0.003918
1/2/2020 	0 	0.294439
1/4/2020 	1 	0.048467
1/5/2020 	0 	0.718177
1/6/2020 	0 	0.001364
1/7/2020 	0 	0.440972
1/8/2020 	0 	0.559622
1/9/2020 	0 	0.821105
1/10/2020 	1 	0.332539
1/11/2020 	0 	0.289809
1/12/2020 	0 	0.911323
1/18/2020 	0 	0.896737
1/19/2020 	0 	0.333354
1/20/2020 	0 	0.19605
1/21/2020 	0 	0.606891
1/22/2020 	1 	0.439834
1/23/2020 	0 	0.896842
1/24/2020 	0 	0.147459
;

data need;
   set have;
   obsnum = _n_;
run;
&lt;/PRE&gt;
&lt;P&gt;The automatic variable _N_ is provided by SAS as a count of the iterations of a data step. If the data simple, as in this case, it will provide a count of the observation position. This assumes that your existing data set is the desired order to impose the 180 rule.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This uses that data set to combine all of the values of your variable and select groups. Caution: if you have large data sets this can take a long time to run.&lt;/P&gt;
&lt;PRE&gt;proc sql;
   create table need2 as
   select a.obs_date as EventDay,a.obsnum as baseobs
          ,b.obs_date,b.value
   from (select * from need where Event=1) as a
        , 
        need as b
   where b.obsnum between a.obsnum and (180+a.obsnum)
   order by a.obsnum,b.obs_date
   ;
quit;&lt;/PRE&gt;
&lt;P&gt;If you really need that daycount variable:&lt;/P&gt;
&lt;PRE&gt;data want;
   set need2;
   by baseobs;
   retain daycount;
   if first.baseobs then daycount=0;
   else daycount+1;
run;&lt;/PRE&gt;
&lt;P&gt;Is 180 a surrogate for 6 Months? If so, then there are better methods than just counting obs.&lt;/P&gt;
&lt;P&gt;Also, if there are any other variables that go along with this process, such as group id membership, then there will be more code needed to make sure that the observations are processed within group only.&lt;/P&gt;</description>
      <pubDate>Fri, 26 May 2023 21:28:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Expanding-the-data-set-for-each-event-day/m-p/877794#M346770</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2023-05-26T21:28:59Z</dc:date>
    </item>
    <item>
      <title>Re: Expanding the data set for each event day</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Expanding-the-data-set-for-each-event-day/m-p/877798#M346774</link>
      <description>&lt;P&gt;Piggybacking on&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13884"&gt;@ballardw&lt;/a&gt;&amp;nbsp;'s creation of the SAS sample data set HAVE, here is a data step solution:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;;
   input obs_date :mmddyy10. 	event 	value;
   format obs_date mmddyy10.;
datalines;
1/1/2020 	0 	0.003918
1/2/2020 	0 	0.294439
1/4/2020 	1 	0.048467
1/5/2020 	0 	0.718177
1/6/2020 	0 	0.001364
1/7/2020 	0 	0.440972
1/8/2020 	0 	0.559622
1/9/2020 	0 	0.821105
1/10/2020 	1 	0.332539
1/11/2020 	0 	0.289809
1/12/2020 	0 	0.911323
1/18/2020 	0 	0.896737
1/19/2020 	0 	0.333354
1/20/2020 	0 	0.19605
1/21/2020 	0 	0.606891
1/22/2020 	1 	0.439834
1/23/2020 	0 	0.896842
1/24/2020 	0 	0.147459
;


data want (drop=event);
  set have (where=(event=1));

  if _n_=1 then do;
    declare hash h (dataset:'have (drop=event)',ordered:'a');
      h.definekey('obs_date');
      h.definedata(all:'Y');
      h.definedone();
    declare hiter hi ('h');
    h.output(dataset:'h');
  end;

  day=0;
  eventday=obs_date;
  format eventday date9.;
  output;
  hi.setcur();  /*Point hash iterator at hash dataitem for event date */
  do day=1 to 180 while (hi.next()=0);
    output;
  end;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If you change the 180 to 10, for this sample data, you'll see that the window stop criterion is properly applied.&amp;nbsp; But note this program assumes that there is never an instance of multiple observations per obs_date.&amp;nbsp; The program does NOT require dataset HAVE to be sorted.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The "trick" here is the &lt;EM&gt;&lt;STRONG&gt;WHILE (hi.next()=0)&lt;/STRONG&gt;&lt;/EM&gt; condition, which forces the hash iterator to advance (i.e. to retrieve the next OBS_DATE) at the start of each iteration of the DO DAY=1 ... loop.&amp;nbsp; If the &lt;STRONG&gt;hi.next()&lt;/STRONG&gt; fails (end of data), it returns a non-zero code, stopping the DO loop before the output statement is executed.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;However, this program will NOT guarantee only complete 180 (181 actually) day windows.&amp;nbsp; Will you be satisfied with the possibility of short windows at the end of the date range?&amp;nbsp; It all depends on how many obs follow the last event=1 case.&lt;/P&gt;</description>
      <pubDate>Fri, 26 May 2023 22:00:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Expanding-the-data-set-for-each-event-day/m-p/877798#M346774</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2023-05-26T22:00:13Z</dc:date>
    </item>
    <item>
      <title>Re: Expanding the data set for each event day</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Expanding-the-data-set-for-each-event-day/m-p/877803#M346778</link>
      <description>&lt;P&gt;Thank you so much &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13884"&gt;@ballardw&lt;/a&gt;&amp;nbsp; and &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/31461"&gt;@mkeintz&lt;/a&gt; for helping me with my inquiry. I really appreciated it. My data set extremely large, so perhaps the data step solution may work better for me. Please accept my apologies. The data set does have IDs, and I need to ensure that these steps are executed within the same IDs only.&amp;nbsp; I did not work with hash operators before. How should I go about bringing in the IDs? I attempted below (bold line), but ended up getting something different.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also: I opted for 180 days instead of 6 months since I need to have 180 observations for each event, and the 6-month cutoff may not necessarily produce 180 observations. If for some events, I have fewer than 180 observations (due to data limitations), this will be fine. I will first run the estimations with only those with 180 observations first, and later I will include all of them (even those with fewer than 180 observations).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data have;;&lt;BR /&gt;input secid obs_date :mmddyy10. event value;&lt;BR /&gt;format obs_date mmddyy10.;&lt;BR /&gt;datalines;&lt;BR /&gt;1 1/1/2020 0 0.003918297&lt;BR /&gt;1 1/2/2020 0 0.294439369&lt;BR /&gt;1 1/4/2020 1 0.048466828&lt;BR /&gt;1 1/5/2020 0 0.718177034&lt;BR /&gt;1 1/6/2020 0 0.001364211&lt;BR /&gt;1 1/7/2020 0 0.440971903&lt;BR /&gt;1 1/8/2020 0 0.55962246&lt;BR /&gt;1 1/9/2020 0 0.821105414&lt;BR /&gt;1 1/10/2020 1 0.332539126&lt;BR /&gt;1 1/11/2020 0 0.289808782&lt;BR /&gt;1 1/12/2020 0 0.911322784&lt;BR /&gt;1 1/18/2020 0 0.896737429&lt;BR /&gt;1 1/19/2020 0 0.333353538&lt;BR /&gt;1 1/20/2020 0 0.19605047&lt;BR /&gt;1 1/21/2020 0 0.60689124&lt;BR /&gt;1 1/22/2020 1 0.439833751&lt;BR /&gt;1 1/23/2020 0 0.896841702&lt;BR /&gt;1 1/24/2020 0 0.147458515&lt;BR /&gt;1 1/25/2020 0 0.923237859&lt;BR /&gt;1 1/26/2020 0 0.394894147&lt;BR /&gt;1 1/27/2020 0 0.935664763&lt;BR /&gt;1 1/28/2020 0 0.667981258&lt;BR /&gt;1 1/29/2020 1 0.872639458&lt;BR /&gt;1 1/30/2020 0 0.064826005&lt;BR /&gt;1 1/31/2020 0 0.109456422&lt;BR /&gt;1 2/1/2020 0 0.386348541&lt;BR /&gt;1 2/2/2020 0 0.732321068&lt;BR /&gt;1 2/3/2020 0 0.503449099&lt;BR /&gt;2 1/1/2020 0 0.003918297&lt;BR /&gt;2 1/2/2020 0 0.294439369&lt;BR /&gt;2 1/4/2020 1 0.048466828&lt;BR /&gt;2 1/5/2020 0 0.718177034&lt;BR /&gt;2 1/6/2020 0 0.001364211&lt;BR /&gt;2 1/7/2020 0 0.440971903&lt;BR /&gt;2 1/8/2020 0 0.55962246&lt;BR /&gt;2 1/9/2020 0 0.821105414&lt;BR /&gt;2 1/10/2020 1 0.332539126&lt;BR /&gt;2 1/11/2020 0 0.289808782&lt;BR /&gt;2 1/12/2020 0 0.911322784&lt;BR /&gt;2 1/18/2020 0 0.896737429&lt;BR /&gt;2 1/19/2020 0 0.333353538&lt;BR /&gt;2 1/20/2020 0 0.19605047&lt;BR /&gt;2 1/21/2020 0 0.60689124&lt;BR /&gt;2 1/22/2020 1 0.439833751&lt;BR /&gt;2 1/23/2020 0 0.896841702&lt;BR /&gt;2 1/24/2020 0 0.147458515&lt;BR /&gt;2 1/25/2020 0 0.923237859&lt;BR /&gt;2 1/26/2020 0 0.394894147&lt;BR /&gt;2 1/27/2020 0 0.935664763&lt;BR /&gt;2 1/28/2020 0 0.667981258&lt;BR /&gt;2 1/29/2020 1 0.872639458&lt;BR /&gt;2 1/30/2020 0 0.064826005&lt;BR /&gt;2 1/31/2020 0 0.109456422&lt;BR /&gt;2 2/1/2020 0 0.386348541&lt;BR /&gt;2 2/2/2020 0 0.732321068&lt;BR /&gt;2 2/3/2020 0 0.503449099&lt;BR /&gt;2 2/4/2020 0 0.60689124&lt;BR /&gt;2 2/5/2020 0 0.439833751&lt;BR /&gt;2 2/6/2020 0 0.896841702&lt;BR /&gt;2 2/7/2020 0 0.147458515&lt;BR /&gt;2 2/8/2020 0 0.923237859&lt;BR /&gt;;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;data want (drop=event);&lt;BR /&gt;set have (where=(event=1));&lt;BR /&gt;&lt;STRONG&gt;by secid;&lt;/STRONG&gt;&lt;BR /&gt;if _n_=1 then do;&lt;BR /&gt;declare hash h (dataset:'have (drop=event)',ordered:'a');&lt;BR /&gt;h.definekey('obs_date');&lt;BR /&gt;h.definedata(all:'Y');&lt;BR /&gt;h.definedone();&lt;BR /&gt;declare hiter hi ('h');&lt;BR /&gt;h.output(dataset:'h');&lt;BR /&gt;end;&lt;/P&gt;
&lt;P&gt;day=0;&lt;BR /&gt;eventday=obs_date;&lt;BR /&gt;format eventday date9.;&lt;BR /&gt;output;&lt;BR /&gt;hi.setcur(); /*Point hash iterator at hash dataitem for event date */&lt;BR /&gt;do day=1 to 180 while (hi.next()=0);&lt;BR /&gt;output;&lt;BR /&gt;end;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 26 May 2023 22:42:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Expanding-the-data-set-for-each-event-day/m-p/877803#M346778</guid>
      <dc:creator>finans_sas</dc:creator>
      <dc:date>2023-05-26T22:42:49Z</dc:date>
    </item>
    <item>
      <title>Re: Expanding the data set for each event day</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Expanding-the-data-set-for-each-event-day/m-p/877806#M346779</link>
      <description>&lt;P&gt;For your case don't use a hash object if you're dealing with big data volumes.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Below data step approach requires the source data to be sorted by secid and obs_date.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I've added three different selection options - pick the one you need.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
  set have;
  by secid obs_date;

  retain day_count _start_dt;
  if first.secid then 
    do;
      day_count=0;
      _start_dt=obs_date;
    end;
  
  if event=0 then day_count+1;

  /* logic for picking the first 180 rows per secid where event=0 */
  if day_count&amp;lt;=180 then output;

  /* logic for picking the first 6 months of rows per secid where event=0 */
  if intck('month',_start_dt,obs_date)&amp;lt;6 then output;

  /* logic for picking the first 6 months of rows per secid where event=0; but never more than 180 rows*/
  if intck('month',_start_dt,obs_date)&amp;lt;6 and day_count&amp;lt;=180 then output;

  drop _start_dt;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 26 May 2023 23:49:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Expanding-the-data-set-for-each-event-day/m-p/877806#M346779</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2023-05-26T23:49:56Z</dc:date>
    </item>
    <item>
      <title>Re: Expanding the data set for each event day</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Expanding-the-data-set-for-each-event-day/m-p/877809#M346782</link>
      <description>&lt;P&gt;Thank you so much &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/12447"&gt;@Patrick&lt;/a&gt; for this suggestion. When I ran it, it did not quite produce the dataset I would like to have. day_count starts for the first observation in the sample and goes all the way till the end of the sample instead of starting at each secid &amp;amp; eventday=1 pairs. Should I create an ID that combines secid and event day to accomplish this task?&lt;/P&gt;
&lt;P&gt;Thank you so much&lt;/P&gt;</description>
      <pubDate>Sat, 27 May 2023 00:24:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Expanding-the-data-set-for-each-event-day/m-p/877809#M346782</guid>
      <dc:creator>finans_sas</dc:creator>
      <dc:date>2023-05-27T00:24:04Z</dc:date>
    </item>
    <item>
      <title>Re: Expanding the data set for each event day</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Expanding-the-data-set-for-each-event-day/m-p/877810#M346783</link>
      <description>&lt;P&gt;I thought you asked for selection logic by secid. If that's not the case then the source data for the data want step would need to be sorted by date only.&lt;/P&gt;
&lt;P&gt;If you just need a consecutive row_count then just don't reset the counter when a new secid starts (the bit under the if first.secid condition).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 27 May 2023 00:42:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Expanding-the-data-set-for-each-event-day/m-p/877810#M346783</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2023-05-27T00:42:07Z</dc:date>
    </item>
    <item>
      <title>Re: Expanding the data set for each event day</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Expanding-the-data-set-for-each-event-day/m-p/877814#M346787</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/12447"&gt;@Patrick&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;I thought you asked for selection logic by secid. If that's not the case then the source data for the data want step would need to be sorted by date only.&lt;/P&gt;
&lt;P&gt;If you just need a consecutive row_count then just don't reset the counter when a new secid starts (the bit under the if first.secid condition).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Part of the headache is that he wants overlapping output each time an "event" happens. So when an event occurs within the 180 days such as from the example below he wants 180 observations starting on 1/4/2020 then another sequence of 180 starting on 1/10/2020 and the two will have 175 observation dates in common.&lt;/P&gt;
&lt;TABLE width="196"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD&gt;1/4/2020&lt;/TD&gt;
&lt;TD&gt;1&lt;/TD&gt;
&lt;TD&gt;0.048467&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;1/5/2020&lt;/TD&gt;
&lt;TD&gt;0&lt;/TD&gt;
&lt;TD&gt;0.718177&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;1/6/2020&lt;/TD&gt;
&lt;TD&gt;0&lt;/TD&gt;
&lt;TD&gt;0.001364&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;1/7/2020&lt;/TD&gt;
&lt;TD&gt;0&lt;/TD&gt;
&lt;TD&gt;0.440972&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;1/8/2020&lt;/TD&gt;
&lt;TD&gt;0&lt;/TD&gt;
&lt;TD&gt;0.559622&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;1/9/2020&lt;/TD&gt;
&lt;TD&gt;0&lt;/TD&gt;
&lt;TD&gt;0.821105&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;1/10/2020&lt;/TD&gt;
&lt;TD&gt;1&lt;/TD&gt;
&lt;TD&gt;0.332539&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;</description>
      <pubDate>Sat, 27 May 2023 01:24:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Expanding-the-data-set-for-each-event-day/m-p/877814#M346787</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2023-05-27T01:24:23Z</dc:date>
    </item>
    <item>
      <title>Re: Expanding the data set for each event day</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Expanding-the-data-set-for-each-event-day/m-p/877816#M346789</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/1906"&gt;@finans_sas&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Thank you so much &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13884"&gt;@ballardw&lt;/a&gt;&amp;nbsp; and &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/31461"&gt;@mkeintz&lt;/a&gt; for helping me with my inquiry. I really appreciated it. My data set extremely large, so perhaps the data step solution may work better for me. Please accept my apologies. The data set does have IDs, and I need to ensure that these steps are executed within the same IDs only.&amp;nbsp; I did not work with hash operators before. How should I go about bringing in the IDs? I attempted below (bold line), but ended up getting something different.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;This mod to my code may work to limit the matches within Secid (security id perhaps as in market trading?)&lt;/P&gt;
&lt;PRE&gt;roc sql;
   create table need2 as
   select a.secid, a.obs_date as EventDay,a.obsnum as baseobs
          ,b.obs_date,b.value
   from (select * from need where Event=1) as a
        , 
        need as b
   where a.secid=b.secid and ( b.obsnum between a.obsnum and (180+a.obsnum) )
   order by a.secid, a.obsnum,b.obs_date
   ;
quit;&lt;/PRE&gt;
&lt;P&gt;And the data step to number:&lt;/P&gt;
&lt;PRE&gt;data want;
   set need2;
   by secid baseobs;
   retain daycount;
   if first.baseobs then daycount=0;
   else daycount+1;
run;&lt;/PRE&gt;
&lt;P&gt;Many times we will recommend not splitting data but since the logic you want for SQL (join on ranges) ends up with cartesian joins and Hash might have memory issues you might consider creating a set for each Secid value and use either approach with the reduced set.&lt;/P&gt;
&lt;P&gt;Or schedule the job to run at night and see if it finishes before you come into work the next day...&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 27 May 2023 01:34:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Expanding-the-data-set-for-each-event-day/m-p/877816#M346789</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2023-05-27T01:34:07Z</dc:date>
    </item>
    <item>
      <title>Re: Expanding the data set for each event day</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Expanding-the-data-set-for-each-event-day/m-p/877888#M346823</link>
      <description>&lt;P&gt;If your data are sorted by SECID, you can use hash objects for each secid, then clear them to conserve memory for the next SECID.&amp;nbsp; I say clear&lt;EM&gt;&lt;STRONG&gt; them&lt;/STRONG&gt;&lt;/EM&gt; (not clear it), because the program below uses a second hash object - for the event=1 observations:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
data have;;
  input secid obs_date :mmddyy10. event value;
  format obs_date mmddyy10.;
datalines;
1 1/1/2020 0 0.003918297
1 1/2/2020 0 0.294439369
1 1/4/2020 1 0.048466828
1 1/5/2020 0 0.718177034
1 1/6/2020 0 0.001364211
1 1/7/2020 0 0.440971903
1 1/8/2020 0 0.55962246
1 1/9/2020 0 0.821105414
1 1/10/2020 1 0.332539126
1 1/11/2020 0 0.289808782
1 1/12/2020 0 0.911322784
1 1/18/2020 0 0.896737429
1 1/19/2020 0 0.333353538
1 1/20/2020 0 0.19605047
1 1/21/2020 0 0.60689124
1 1/22/2020 1 0.439833751
1 1/23/2020 0 0.896841702
1 1/24/2020 0 0.147458515
1 1/25/2020 0 0.923237859
1 1/26/2020 0 0.394894147
1 1/27/2020 0 0.935664763
1 1/28/2020 0 0.667981258
1 1/29/2020 1 0.872639458
1 1/30/2020 0 0.064826005
1 1/31/2020 0 0.109456422
1 2/1/2020 0 0.386348541
1 2/2/2020 0 0.732321068
1 2/3/2020 0 0.503449099
2 1/1/2020 0 0.003918297
2 1/2/2020 0 0.294439369
2 1/4/2020 1 0.048466828
2 1/5/2020 0 0.718177034
2 1/6/2020 0 0.001364211
2 1/7/2020 0 0.440971903
2 1/8/2020 0 0.55962246
2 1/9/2020 0 0.821105414
2 1/10/2020 1 0.332539126
2 1/11/2020 0 0.289808782
2 1/12/2020 0 0.911322784
2 1/18/2020 0 0.896737429
2 1/19/2020 0 0.333353538
2 1/20/2020 0 0.19605047
2 1/21/2020 0 0.60689124
2 1/22/2020 1 0.439833751
2 1/23/2020 0 0.896841702
2 1/24/2020 0 0.147458515
2 1/25/2020 0 0.923237859
2 1/26/2020 0 0.394894147
2 1/27/2020 0 0.935664763
2 1/28/2020 0 0.667981258
2 1/29/2020 1 0.872639458
2 1/30/2020 0 0.064826005
2 1/31/2020 0 0.109456422
2 2/1/2020 0 0.386348541
2 2/2/2020 0 0.732321068
2 2/3/2020 0 0.503449099
2 2/4/2020 0 0.60689124
2 2/5/2020 0 0.439833751
2 2/6/2020 0 0.896841702
2 2/7/2020 0 0.147458515
2 2/8/2020 0 0.923237859
;



data want (drop=event);
  if _n_=1 then do;
    if 0 then set have;
    declare hash h (dataset:'have (obs=0 drop=event)',ordered:'a');
      h.definekey('obs_date');
      h.definedata(all:'Y');
      h.definedone();
    declare hiter hi ('h');

    declare hash ev (dataset:'have (obs=0 drop=event)',ordered:'a');
      ev.definekey('obs_date');
      ev.definedata(all:'Y');
      ev.definedone();
    declare hiter evi ('ev');
  end;

  do until (last.secid);  /*populate hash objects for a single SECID*/
    set have;
    by secid;
    h.add();
    if event=1 then ev.add();
  end;

  do while (evi.next()=0);
    day=0;
    eventday=obs_date;   format eventday date9.;
    output;

    hi.setcur();  /*Point hash iterator at hash dataitem for event date */
    do day=1 to 180 while (hi.next()=0);
      output;
    end;
  end;
  ev.clear();
  h.clear();
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The above needs the data to be sorted by SECID, but the data don't have to be sorted by obs_date within SECID.&lt;/P&gt;</description>
      <pubDate>Sun, 28 May 2023 04:03:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Expanding-the-data-set-for-each-event-day/m-p/877888#M346823</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2023-05-28T04:03:14Z</dc:date>
    </item>
    <item>
      <title>Re: Expanding the data set for each event day</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Expanding-the-data-set-for-each-event-day/m-p/877894#M346827</link>
      <description>&lt;P&gt;Thanks&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13884"&gt;@ballardw&lt;/a&gt;&amp;nbsp;for pointing out where I missed what the OP asked for.&lt;/P&gt;
&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/1906"&gt;@finans_sas&lt;/a&gt;&amp;nbsp; Below should work.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
  set have(keep=secid obs_date event rename=(secid=_secid obs_date=_obs_date));
  by _secid _obs_date;
  if event=1;

  day_count=0;

  do _i=_n_ to _nobs;
    set have point=_i  nobs=_nobs;
    if _secid ne secid then leave;

/*    if day_count&amp;gt;179 then leave;*/

    if intck('month',_obs_date,obs_date)&amp;gt;=6 then leave;

    output;
    day_count+1;
  end;
  drop _:;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 28 May 2023 03:54:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Expanding-the-data-set-for-each-event-day/m-p/877894#M346827</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2023-05-28T03:54:21Z</dc:date>
    </item>
    <item>
      <title>Re: Expanding the data set for each event day</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Expanding-the-data-set-for-each-event-day/m-p/877910#M346834</link>
      <description>&lt;P&gt;Thank you so much &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13884"&gt;@ballardw&lt;/a&gt; , &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/12447"&gt;@Patrick&lt;/a&gt; , and &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/31461"&gt;@mkeintz&lt;/a&gt;&amp;nbsp; for helping me with my question. I sincerely appreciated all your help.&lt;/P&gt;
&lt;P&gt;Have a wonderful weekend!&lt;/P&gt;</description>
      <pubDate>Sun, 28 May 2023 09:53:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Expanding-the-data-set-for-each-event-day/m-p/877910#M346834</guid>
      <dc:creator>finans_sas</dc:creator>
      <dc:date>2023-05-28T09:53:58Z</dc:date>
    </item>
  </channel>
</rss>

