<?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 Use time overlaps to update another variable in SAS Studio</title>
    <link>https://communities.sas.com/t5/SAS-Studio/Use-time-overlaps-to-update-another-variable/m-p/391101#M3332</link>
    <description>&lt;P&gt;Hello everyone,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a data like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;U&gt;patient_ID&lt;/U&gt; &amp;nbsp; &amp;nbsp;&lt;U&gt;drug_dose&lt;/U&gt; &amp;nbsp; &amp;nbsp;&lt;U&gt;date_start&lt;/U&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;U&gt;date_stop&lt;/U&gt;&lt;/P&gt;&lt;P&gt;1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;10 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;04/26/2008 &amp;nbsp; &amp;nbsp; &amp;nbsp; 11/10/2008&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;5&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;06/16/2008&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;02/02/2009&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;7 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 10/13/2008&amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp; 11/12/2008&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;2&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 3&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;04/30/2008&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp; 10/27/2008&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;2&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 11&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;08/17/2008&amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp; 05/14/2009&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;...&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;where all &lt;STRONG&gt;start/stop dates have closed intervals.&amp;nbsp;&lt;/STRONG&gt;&lt;/SPAN&gt;Then, I want to have a data like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;U&gt;patient_ID&lt;/U&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&amp;nbsp; &amp;nbsp;&lt;U&gt;drug_dose&lt;/U&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&amp;nbsp; &amp;nbsp;&lt;U&gt;date_start&lt;/U&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;U&gt;date_stop&lt;/U&gt;&lt;/P&gt;&lt;P&gt;1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;10 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;04/26/2008 &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;SPAN&gt; 06/15/2008&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;15 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 06/16/2008&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;10/12/2008&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;22 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 10/13/2008&amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;11/10/2008&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;12&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;11/11/2008&amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;11/12/2008&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 5&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp; 11/13/2008&amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp; 02/02/2009&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;2&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp; 3&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;04/30/2008&amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;08/16/2008&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;2&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;14&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 08/17/2008&amp;nbsp; &amp;nbsp; &amp;nbsp; 10/27/2008&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;2&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;11&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 10/28/2008&amp;nbsp; &amp;nbsp; &amp;nbsp; 05/14/2009&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;...&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;In other words, I want to obtain the whole drug dosage for every time interval for each patient.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I'd be very thankful if anyone has any idea/suggestion!&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Sun, 27 Aug 2017 00:14:26 GMT</pubDate>
    <dc:creator>Alireza_Boloori</dc:creator>
    <dc:date>2017-08-27T00:14:26Z</dc:date>
    <item>
      <title>Use time overlaps to update another variable</title>
      <link>https://communities.sas.com/t5/SAS-Studio/Use-time-overlaps-to-update-another-variable/m-p/391101#M3332</link>
      <description>&lt;P&gt;Hello everyone,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a data like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;U&gt;patient_ID&lt;/U&gt; &amp;nbsp; &amp;nbsp;&lt;U&gt;drug_dose&lt;/U&gt; &amp;nbsp; &amp;nbsp;&lt;U&gt;date_start&lt;/U&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;U&gt;date_stop&lt;/U&gt;&lt;/P&gt;&lt;P&gt;1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;10 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;04/26/2008 &amp;nbsp; &amp;nbsp; &amp;nbsp; 11/10/2008&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;5&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;06/16/2008&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;02/02/2009&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;7 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 10/13/2008&amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp; 11/12/2008&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;2&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 3&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;04/30/2008&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp; 10/27/2008&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;2&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 11&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;08/17/2008&amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp; 05/14/2009&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;...&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;where all &lt;STRONG&gt;start/stop dates have closed intervals.&amp;nbsp;&lt;/STRONG&gt;&lt;/SPAN&gt;Then, I want to have a data like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;U&gt;patient_ID&lt;/U&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&amp;nbsp; &amp;nbsp;&lt;U&gt;drug_dose&lt;/U&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&amp;nbsp; &amp;nbsp;&lt;U&gt;date_start&lt;/U&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;U&gt;date_stop&lt;/U&gt;&lt;/P&gt;&lt;P&gt;1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;10 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;04/26/2008 &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;SPAN&gt; 06/15/2008&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;15 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 06/16/2008&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;10/12/2008&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;22 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 10/13/2008&amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;11/10/2008&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;12&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;11/11/2008&amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;11/12/2008&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 5&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp; 11/13/2008&amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp; 02/02/2009&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;2&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp; 3&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;04/30/2008&amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;08/16/2008&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;2&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;14&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 08/17/2008&amp;nbsp; &amp;nbsp; &amp;nbsp; 10/27/2008&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;2&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;11&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 10/28/2008&amp;nbsp; &amp;nbsp; &amp;nbsp; 05/14/2009&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;...&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;In other words, I want to obtain the whole drug dosage for every time interval for each patient.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I'd be very thankful if anyone has any idea/suggestion!&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 27 Aug 2017 00:14:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/Use-time-overlaps-to-update-another-variable/m-p/391101#M3332</guid>
      <dc:creator>Alireza_Boloori</dc:creator>
      <dc:date>2017-08-27T00:14:26Z</dc:date>
    </item>
    <item>
      <title>Re: Use time overlaps to update another variable</title>
      <link>https://communities.sas.com/t5/SAS-Studio/Use-time-overlaps-to-update-another-variable/m-p/391112#M3333</link>
      <description>&lt;P&gt;If your data isn't too huge, you can simply expand and sum, like this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input patient_ID drug_dose (date_start date_stop) (:mmddyy10.);
format date_start date_stop yymmdd10.;
datalines;
1 10 04/26/2008 11/10/2008
1 5 06/16/2008 02/02/2009
1 7 10/13/2008 11/12/2008
2 3 04/30/2008 10/27/2008
2 11 08/17/2008 05/14/2009
;

data expand;
set have;
do date = date_start to date_stop;
    output;
    end;
format date yymmdd10.;
keep patient_id date drug_dose;
run;

proc sql;
create table sumDoses as
select patient_id, date, sum(drug_dose) as drug_dose
from expand
group by patient_id, date
order by patient_id, date;
quit;

data want;
set sumDoses;
by patient_id drug_dose notsorted;
retain date_start;
if first.drug_dose then date_start =  date;
if last.drug_dose and drug_dose &amp;gt; 0 then do;
    date_stop = date;
    output;
    end;
format date_start date_stop yymmdd10.;
keep patient_id drug_dose date_start date_stop;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Otherwise, if your time period isn't too long, you could use an array (one element per day).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 27 Aug 2017 03:24:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/Use-time-overlaps-to-update-another-variable/m-p/391112#M3333</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2017-08-27T03:24:42Z</dc:date>
    </item>
    <item>
      <title>Re: Use time overlaps to update another variable</title>
      <link>https://communities.sas.com/t5/SAS-Studio/Use-time-overlaps-to-update-another-variable/m-p/391305#M3337</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/462"&gt;@PGStats&lt;/a&gt;&amp;nbsp;Thank you very much! However, based on your comments, my data has 2 problems: I have &amp;gt;= 40 million rows, and the time period is 3 years. Any recommendation?&lt;/P&gt;</description>
      <pubDate>Mon, 28 Aug 2017 19:03:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/Use-time-overlaps-to-update-another-variable/m-p/391305#M3337</guid>
      <dc:creator>Alireza_Boloori</dc:creator>
      <dc:date>2017-08-28T19:03:33Z</dc:date>
    </item>
    <item>
      <title>Re: Use time overlaps to update another variable</title>
      <link>https://communities.sas.com/t5/SAS-Studio/Use-time-overlaps-to-update-another-variable/m-p/391334#M3339</link>
      <description>&lt;P&gt;OK then, the data set&amp;nbsp;is large, but 3 years is not that many days. So here goes an array solution:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input patient_ID drug_dose (date_start date_stop) (:mmddyy10.);
format date_start date_stop yymmdd10.;
datalines;
1 10 04/26/2008 11/10/2008
1 5 06/16/2008 02/02/2009
1 7 10/13/2008 11/12/2008
2 3 04/30/2008 10/27/2008
2 11 08/17/2008 05/14/2009
;

data want;
/* Array subscripts should start before earliest date_start and 
   end after latest date_stop */
%let dstart=%sysfunc(mdy(12,31,2007));
%let dend=%sysfunc(mdy(1,1,2010));
array d{&amp;amp;dstart. : &amp;amp;dend.};
do until(last.patient_id);
    set have; by patient_id;
    do date = date_start to date_stop;
        d{date} = sum(d{date}, drug_dose);
        end;
    end;
do date = &amp;amp;dstart.+1 to &amp;amp;dend.;
    if d{date} ne d{date-1} then do;
        if not missing(date_start) then do;
            date_stop = date-1;
            drug_dose = d{date-1};
            if drug_dose &amp;gt; 0 then output;
            call missing(date_start, drug_dose);
            end;
        date_start = date;
        end;
    end;
format date yymmdd10.;
keep patient_id date_start date_stop drug_dose;
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 28 Aug 2017 21:45:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/Use-time-overlaps-to-update-another-variable/m-p/391334#M3339</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2017-08-28T21:45:41Z</dc:date>
    </item>
    <item>
      <title>Re: Use time overlaps to update another variable</title>
      <link>https://communities.sas.com/t5/SAS-Studio/Use-time-overlaps-to-update-another-variable/m-p/391363#M3340</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/462"&gt;@PGStats&lt;/a&gt;&amp;nbsp;Thank you very much again!&lt;BR /&gt;When I run your code for the period from 12/31/2007 to 1/7/2011, it only gave the results for date_start = '01/01/2008' and date_stop = "01/02/2008'.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It also gave me this error i nthe log window:&lt;/P&gt;&lt;P&gt;ERROR: Array subscript out of range at line 317 column 23.&lt;/P&gt;&lt;P&gt;--&amp;gt; line 317 was related to this line of code: d{date} = sum(d{date}, MME_day);&lt;BR /&gt;d1=. d2=. d3=. d4=. d5=. .....d1099=0 d1100=0 d1101=0 d1102=0 d1103=0 d1104=0&lt;/P&gt;&lt;P&gt;last.ENROLID=1 ENROLID=41102 MME_day=0&lt;BR /&gt;date_start=08/10/2010 date_stop=02/06/2011&lt;/P&gt;&lt;P&gt;FIRST.ENROLID=0 date=01/08/2011 _ERROR_=1 _N_=7&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 29 Aug 2017 01:59:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/Use-time-overlaps-to-update-another-variable/m-p/391363#M3340</guid>
      <dc:creator>Alireza_Boloori</dc:creator>
      <dc:date>2017-08-29T01:59:51Z</dc:date>
    </item>
    <item>
      <title>Re: Use time overlaps to update another variable</title>
      <link>https://communities.sas.com/t5/SAS-Studio/Use-time-overlaps-to-update-another-variable/m-p/391369#M3341</link>
      <description>&lt;P&gt;Given that you have a date_stop of 2011-02-06, I think you meant the array limits to be&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let dstart=%sysfunc(mdy(12,31,2007));
%let dend=%sysfunc(mdy(7,1,2011));
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Make sure these date limits encompass all of your data.&lt;/P&gt;</description>
      <pubDate>Tue, 29 Aug 2017 02:26:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/Use-time-overlaps-to-update-another-variable/m-p/391369#M3341</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2017-08-29T02:26:52Z</dc:date>
    </item>
    <item>
      <title>Re: Use time overlaps to update another variable</title>
      <link>https://communities.sas.com/t5/SAS-Studio/Use-time-overlaps-to-update-another-variable/m-p/392046#M3349</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/462"&gt;@PGStats&lt;/a&gt;&amp;nbsp;Thank you very much! It resolved my problem.&lt;/P&gt;&lt;P&gt;If you don't mind, I have another&amp;nbsp;question: If I have another drug (lets call it drug 2) with different dose (i.e., drug2_dose), how the code above will be changed?&lt;/P&gt;</description>
      <pubDate>Wed, 30 Aug 2017 21:36:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/Use-time-overlaps-to-update-another-variable/m-p/392046#M3349</guid>
      <dc:creator>Alireza_Boloori</dc:creator>
      <dc:date>2017-08-30T21:36:49Z</dc:date>
    </item>
    <item>
      <title>Re: Use time overlaps to update another variable</title>
      <link>https://communities.sas.com/t5/SAS-Studio/Use-time-overlaps-to-update-another-variable/m-p/392053#M3350</link>
      <description>&lt;P&gt;How would you represent cases where a start-stop pair applies to one drug and not the other in your data structure?&lt;/P&gt;</description>
      <pubDate>Wed, 30 Aug 2017 22:34:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/Use-time-overlaps-to-update-another-variable/m-p/392053#M3350</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2017-08-30T22:34:27Z</dc:date>
    </item>
    <item>
      <title>Re: Use time overlaps to update another variable</title>
      <link>https://communities.sas.com/t5/SAS-Studio/Use-time-overlaps-to-update-another-variable/m-p/392054#M3351</link>
      <description>Well, the start-stop pair applies to both. Basically, I do have two drugs prescribed simultaneously. So, for every start-stop pair, I do have two drugs.&lt;BR /&gt;I'm sorry for this as I should have mentioned this first.</description>
      <pubDate>Wed, 30 Aug 2017 22:36:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/Use-time-overlaps-to-update-another-variable/m-p/392054#M3351</guid>
      <dc:creator>Alireza_Boloori</dc:creator>
      <dc:date>2017-08-30T22:36:43Z</dc:date>
    </item>
    <item>
      <title>Re: Use time overlaps to update another variable</title>
      <link>https://communities.sas.com/t5/SAS-Studio/Use-time-overlaps-to-update-another-variable/m-p/392074#M3352</link>
      <description>&lt;P&gt;Extension to two drugs is pretty straitforward. The data could also include zeros for drug1_dose or drug2_dose if only one was given over a certain period.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input patient_ID drug1_dose drug2_dose (date_start date_stop) (:mmddyy10.);
format date_start date_stop yymmdd10.;
datalines;
1 10  1  04/26/2008 11/10/2008
1 5  15  06/16/2008 02/02/2009
1 7  17  10/13/2008 11/12/2008
2 3  13  04/30/2008 10/27/2008
2 11  1  08/17/2008 05/14/2009
;

data want;

/* Array subscripts should start before earliest date_start and 
   end after latest date_stop */
%let dstart=%sysfunc(mdy(12,31,2007));
%let dend=%sysfunc(mdy(7,1,2011));

array d1{&amp;amp;dstart. : &amp;amp;dend.};
array d2{&amp;amp;dstart. : &amp;amp;dend.};
do until(last.patient_id);
    set have; by patient_id;
    do date = date_start to date_stop;
        d1{date} = sum(d1{date}, drug1_dose);
        d2{date} = sum(d2{date}, drug2_dose);
        end;
    end;
do date = &amp;amp;dstart.+1 to &amp;amp;dend.;
    if d1{date} ne d1{date-1} or d2{date} ne d2{date-1} then do;
        if not missing(date_start) then do;
            date_stop = date-1;
            drug1_dose = d1{date-1};
            drug2_dose = d2{date-1};
            if drug1_dose &amp;gt; 0 or drug2_dose &amp;gt; 0 then output;
            call missing(date_start, drug1_dose, drug2_dose);
            end;
        date_start = date;
        end;
    end;
format date yymmdd10.;
keep patient_id date_start date_stop drug1_dose drug2_dose;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 31 Aug 2017 03:26:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/Use-time-overlaps-to-update-another-variable/m-p/392074#M3352</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2017-08-31T03:26:02Z</dc:date>
    </item>
    <item>
      <title>Re: Use time overlaps to update another variable</title>
      <link>https://communities.sas.com/t5/SAS-Studio/Use-time-overlaps-to-update-another-variable/m-p/392404#M3353</link>
      <description>&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/462"&gt;@PGStats&lt;/a&gt; I really appreciate your time and help!</description>
      <pubDate>Fri, 01 Sep 2017 02:23:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/Use-time-overlaps-to-update-another-variable/m-p/392404#M3353</guid>
      <dc:creator>Alireza_Boloori</dc:creator>
      <dc:date>2017-09-01T02:23:49Z</dc:date>
    </item>
    <item>
      <title>Re: Use time overlaps to update another variable</title>
      <link>https://communities.sas.com/t5/SAS-Studio/Use-time-overlaps-to-update-another-variable/m-p/436036#M4609</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/462"&gt;@PGStats&lt;/a&gt;&amp;nbsp;Regarding the last code, what happens if I have another variable. Let say, this is the data that I have (where I add variable "category"):&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input patient_ID category drug_dose (date_start date_stop) (:mmddyy10.);
format date_start date_stop yymmdd10.;
datalines;
1 1 10 04/26/2008 11/10/2008
1 1 5 06/16/2008 02/02/2009
1 2 7 10/13/2008 11/12/2008
2 1 3 04/30/2008 10/27/2008
2 2 11 08/17/2008 05/14/2009
;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;and this the data I want to have&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
input patient_ID category drug_dose (date_start date_stop) (:mmddyy10.);
format date_start date_stop yymmdd10.;
datalines;
1 1 10 04/26/2008 06/15/2008
1 1 15 06/16/2008 11/10/2008
1 1 5 11/11/2008 02/02/2009
1 2 7 10/13/2008 11/12/2008
2 1 3 04/30/2008 10/27/2008
2 2 11 08/17/2008 05/14/2009
;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;I tried the second option you provided (using sql and expanding the data), but my data is very huge and I run out of space. So, I'd be very thankful if you direct me in this case.&lt;/P&gt;</description>
      <pubDate>Sun, 11 Feb 2018 01:30:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/Use-time-overlaps-to-update-another-variable/m-p/436036#M4609</guid>
      <dc:creator>Alireza_Boloori</dc:creator>
      <dc:date>2018-02-11T01:30:24Z</dc:date>
    </item>
    <item>
      <title>Re: Use time overlaps to update another variable</title>
      <link>https://communities.sas.com/t5/SAS-Studio/Use-time-overlaps-to-update-another-variable/m-p/436071#M4611</link>
      <description>&lt;P&gt;If your category takes values 1 and 2 then the last solution I provided (for drug1 and drug2)&amp;nbsp;is simple to&amp;nbsp;adapt and will not consume much memory.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You could also process each category separately for each patient&amp;nbsp;by sorting by patientId and category and loop until(last.category).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you run into problems, post the code you have tried and the messages and/or results that you got.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 11 Feb 2018 05:23:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/Use-time-overlaps-to-update-another-variable/m-p/436071#M4611</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2018-02-11T05:23:59Z</dc:date>
    </item>
  </channel>
</rss>

