<?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: How to  look at certain period in time in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-look-at-certain-period-in-time/m-p/639324#M190177</link>
    <description>&lt;P&gt;And what should the output be for this revised data set?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;ID A has three admissions dated 01JAN2001, are these counted as three different admissions, or one admission?&lt;/P&gt;</description>
    <pubDate>Sun, 12 Apr 2020 14:33:28 GMT</pubDate>
    <dc:creator>PaigeMiller</dc:creator>
    <dc:date>2020-04-12T14:33:28Z</dc:date>
    <item>
      <title>How to  look at certain period in time</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-look-at-certain-period-in-time/m-p/639289#M190146</link>
      <description>&lt;P&gt;Hi all,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have data that looks like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;        Date          Date               
 ID   registration  admission    Echo     

 A    01JAN2001    01JAN2001      1         
 A    07JAN2001        .          0         
 A    15JAN2001        .          1         
 A    15MAR2001        .          1         
 B    07MAR2005        .          1       
 B    10MAR2005    10MAR2005      0         
 B    21MAR2005    21MAR2005      1          &lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;I need to flag the sum of the echo's within 42 days from admission. There can be more than one admission in my data and it can only count the echo's of this last admission. Any ideas?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What I want:&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;LI-CODE lang="markup"&gt;        Date          Date                Number 
 ID   registration  admission    Echo     of Echo

 A    01JAN2001    01JAN2001      1          2
 A    07JAN2001        .          0          2
 A    15JAN2001        .          1          2
 A    15MAR2001        .          1          .
 B    07MAR2005        .          1          .
 B    10MAR2005    10MAR2005      0          1
 B    21MAR2005    21MAR2005      1          1&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;All help would be greatly appreciated!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 12 Apr 2020 11:36:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-look-at-certain-period-in-time/m-p/639289#M190146</guid>
      <dc:creator>fouke_o</dc:creator>
      <dc:date>2020-04-12T11:36:18Z</dc:date>
    </item>
    <item>
      <title>Re: How to  look at certain period in time</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-look-at-certain-period-in-time/m-p/639292#M190149</link>
      <description>&lt;P&gt;Please correct your input data set. There are rows in the output that are not present in the input, and so we cannot possibly match the output unless you correct the input.&lt;/P&gt;</description>
      <pubDate>Sun, 12 Apr 2020 11:11:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-look-at-certain-period-in-time/m-p/639292#M190149</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2020-04-12T11:11:17Z</dc:date>
    </item>
    <item>
      <title>Re: How to  look at certain period in time</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-look-at-certain-period-in-time/m-p/639294#M190151</link>
      <description>'last admission' mean the last admission date within each id group ?&lt;BR /&gt;&lt;BR /&gt; " within 42 days from admission" means [  admission date-42 , admission date+42 ]  ?</description>
      <pubDate>Sun, 12 Apr 2020 11:35:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-look-at-certain-period-in-time/m-p/639294#M190151</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2020-04-12T11:35:51Z</dc:date>
    </item>
    <item>
      <title>Re: How to  look at certain period in time</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-look-at-certain-period-in-time/m-p/639295#M190152</link>
      <description>&lt;P&gt;Hello,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;yes, sorry, it mean the last occurrence of admission date for this ID group.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 12 Apr 2020 11:37:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-look-at-certain-period-in-time/m-p/639295#M190152</guid>
      <dc:creator>fouke_o</dc:creator>
      <dc:date>2020-04-12T11:37:37Z</dc:date>
    </item>
    <item>
      <title>Re: How to  look at certain period in time</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-look-at-certain-period-in-time/m-p/639297#M190154</link>
      <description>&lt;P&gt;Assumes data is sorted by ID and admission date;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt; data have;
 input  ID $  registration :date9. admission :date9. Echo;
 retain admission1;
 prev_id=lag(id);
 if not missing(admission) or prev_id^=id then admission1=admission;
 if registration-admission1&amp;lt;=42 then within_time_period=1; else within_time_period=0;
 format registration admission date9.;
 drop prev_id;
 cards;
 A    01JAN2001    01JAN2001      1         
 A    07JAN2001        .          0         
 A    15JAN2001        .          1         
 A    15MAR2001        .          1         
 B    07MAR2005        .          1       
 B    10MAR2005    10MAR2005      0         
 B    21MAR2005    21MAR2005      1   
 ;
 proc summary data=have nway;
 	class id admission1;
 	var echo/weight=within_time_period;
 	output out=sums(drop=_:) sum=number_of_echo;
 run;
 data want;
     merge have sums;
     by id admission1;
     if within_time_period=0 then number_of_echo=.;
     drop admission1 within_time_period;
 run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 12 Apr 2020 11:51:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-look-at-certain-period-in-time/m-p/639297#M190154</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2020-04-12T11:51:19Z</dc:date>
    </item>
    <item>
      <title>Re: How to  look at certain period in time</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-look-at-certain-period-in-time/m-p/639303#M190160</link>
      <description>Why not include B 07MAR2005 ? since   07MAR2005 - 21MAR2005  is within 42 days .</description>
      <pubDate>Sun, 12 Apr 2020 12:02:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-look-at-certain-period-in-time/m-p/639303#M190160</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2020-04-12T12:02:08Z</dc:date>
    </item>
    <item>
      <title>Re: How to  look at certain period in time</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-look-at-certain-period-in-time/m-p/639312#M190168</link>
      <description>&lt;P&gt;OK. Assuming I understand what you mean and don't have a big table.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
 input  ID $  registration :date9. admission :date9.  Echo;
 format registration admission  date9.;
 cards;
 A    01JAN2001    01JAN2001      1         
 A    07JAN2001        .          0         
 A    15JAN2001        .          1         
 A    15MAR2001        .          1         
 B    07MAR2005        .          1       
 B    10MAR2005    10MAR2005      0         
 B    21MAR2005    21MAR2005      1   
 ;
data have;
 set have;
 by id;
 retain _admin;
 if first.id then call missing(_admin);
 if not missing(admission) then _admin=admission;
 format _admin date9.;
run;
proc sql;
create table want as
 select *,case when .&amp;lt;registration-_admin&amp;lt;=42 then
 (select sum(echo) from have where id=a.id and 
  registration between a._admin and a._admin+42 )
  else 0 end as number_of_echo
  from have as a;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 12 Apr 2020 12:27:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-look-at-certain-period-in-time/m-p/639312#M190168</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2020-04-12T12:27:56Z</dc:date>
    </item>
    <item>
      <title>Re: How to  look at certain period in time</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-look-at-certain-period-in-time/m-p/639320#M190175</link>
      <description>&lt;P&gt;Because this occurrs before the admission date.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 12 Apr 2020 13:55:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-look-at-certain-period-in-time/m-p/639320#M190175</guid>
      <dc:creator>fouke_o</dc:creator>
      <dc:date>2020-04-12T13:55:31Z</dc:date>
    </item>
    <item>
      <title>Re: How to  look at certain period in time</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-look-at-certain-period-in-time/m-p/639322#M190176</link>
      <description>&lt;P&gt;I think I need to be more specific, apologies.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a dataset of 10million records, where the structure looks more like this:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;        Date          Date               
 ID   registration  admission    Echo     

 A    01JAN2001    01JAN2001      1         
 A    07JAN2001        .          0   
 A    15JAN2001    01JAN2001      0
 A    15JAN2001    01JAN2001      0
 A    15JAN2001        .          1         
 A    15MAR2001        .          1   
 A    18MAR2001    18MAR2001      0  
 A    18MAR2001    18MAR2001      0 
 A    19MAR2001    18MAR2001      1
 A    20MAR2001        .          0
 A    22MAR2001    18MAR2001      1       
 B    07MAR2005        .          1       
 B    10MAR2005    10MAR2005      0         
 B    21MAR2005    21MAR2005      1 
 B    23MAR2005        .          0&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is offcourse just an example, because 10million would be a bit much.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Roughly each ID has over 1000 records, of which there can be several admissions. I only want to count the occurence of echo when it is within the 42 days of the last date of admission. Both codes provided here do not seem to work.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 12 Apr 2020 14:25:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-look-at-certain-period-in-time/m-p/639322#M190176</guid>
      <dc:creator>fouke_o</dc:creator>
      <dc:date>2020-04-12T14:25:04Z</dc:date>
    </item>
    <item>
      <title>Re: How to  look at certain period in time</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-look-at-certain-period-in-time/m-p/639324#M190177</link>
      <description>&lt;P&gt;And what should the output be for this revised data set?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;ID A has three admissions dated 01JAN2001, are these counted as three different admissions, or one admission?&lt;/P&gt;</description>
      <pubDate>Sun, 12 Apr 2020 14:33:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-look-at-certain-period-in-time/m-p/639324#M190177</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2020-04-12T14:33:28Z</dc:date>
    </item>
    <item>
      <title>Re: How to  look at certain period in time</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-look-at-certain-period-in-time/m-p/639325#M190178</link>
      <description>&lt;P&gt;Hi,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;this is what I would like to have, the sum of the echo's within 42 days from the admission&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;        Date          Date                 Echo_
 ID   registration  admission    Echo     Count

 A    01JAN2001    01JAN2001      1         2  
 A    07JAN2001        .          0         2
 A    15JAN2001    01JAN2001      0         2
 A    15JAN2001    01JAN2001      0         2
 A    15JAN2001        .          1         2 
 A    15MAR2001        .          1         .
 A    18MAR2001    18MAR2001      0         2
 A    18MAR2001    18MAR2001      0         2
 A    19MAR2001    18MAR2001      1         2
 A    20MAR2001        .          0         2
 A    22MAR2001    18MAR2001      1         2      
 B    07MAR2005        .          1         .
 B    10MAR2005    10MAR2005      0         1
 B    21MAR2005    21MAR2005      1         1
 B    23MAR2005        .          0         1&lt;/LI-CODE&gt;</description>
      <pubDate>Sun, 12 Apr 2020 14:32:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-look-at-certain-period-in-time/m-p/639325#M190178</guid>
      <dc:creator>fouke_o</dc:creator>
      <dc:date>2020-04-12T14:32:28Z</dc:date>
    </item>
    <item>
      <title>Re: How to  look at certain period in time</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-look-at-certain-period-in-time/m-p/639326#M190179</link>
      <description>&lt;P&gt;As far as I can see, the solution I provided earlier ought to work on the revised data.&lt;/P&gt;</description>
      <pubDate>Sun, 12 Apr 2020 14:34:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-look-at-certain-period-in-time/m-p/639326#M190179</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2020-04-12T14:34:20Z</dc:date>
    </item>
    <item>
      <title>Re: How to  look at certain period in time</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-look-at-certain-period-in-time/m-p/639340#M190187</link>
      <description>&lt;P&gt;Thank you, indeed it worked!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 12 Apr 2020 17:10:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-look-at-certain-period-in-time/m-p/639340#M190187</guid>
      <dc:creator>fouke_o</dc:creator>
      <dc:date>2020-04-12T17:10:50Z</dc:date>
    </item>
  </channel>
</rss>

