<?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: Partition by equivalent in SAS base or proc sql in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Partition-by-equivalent-in-SAS-base-or-proc-sql/m-p/416355#M280184</link>
    <description>&lt;P&gt;I'm testing this code now, but it works about 1 hour, and still counting, I don't know why,&amp;nbsp;it looks good.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Maybe there is need for some sorting data before aggregation?&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you for your reply.&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 27 Nov 2017 12:34:49 GMT</pubDate>
    <dc:creator>jovic92</dc:creator>
    <dc:date>2017-11-27T12:34:49Z</dc:date>
    <item>
      <title>Partition by equivalent in SAS base or proc sql</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Partition-by-equivalent-in-SAS-base-or-proc-sql/m-p/415993#M280182</link>
      <description>&lt;P&gt;Hi, everyone,&lt;/P&gt;&lt;P&gt;What is needed is to calculate for every record (every row) the last 3hr sum of usage (Usage is one of the columns in dataset) grouped by User and ID_option.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Every line(row) represent one record (within 3 min time interval). For example (including desired column sum_usage):&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;User  ID_option          time             usage        sum_usage_3hr
1         a1        12OCT2017:11:20:32       3             10
1         a1        12OCT2017:10:23:24       7             14
1         b1        12OCT2017:09:34:55       12            12
2         b1        12OCT2017:08:55:06       4              6
1         a1        12OCT2017:07:59:53       7              7
2         b1        12OCT2017:06:59:12       2              2&lt;/PRE&gt;&lt;P&gt;I have tried with something like this code below, and it return me sum of all time, not just the last 3HR. I'm not surprised, but have not so much idea how I'm going to do this in sas.&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql:
CREATE table my_table
SELECT *, SUM(usage) AS sum_usage_3hr
FROM prev_table WHERE time BETWEEN TIME and intnx('second', time, -3*3600)
GROUP BY User, ID_option;
RUN;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;Any help is welcomed, thanks.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 24 Nov 2017 12:07:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Partition-by-equivalent-in-SAS-base-or-proc-sql/m-p/415993#M280182</guid>
      <dc:creator>jovic92</dc:creator>
      <dc:date>2017-11-24T12:07:57Z</dc:date>
    </item>
    <item>
      <title>Re: Partition by equivalent in SAS base or proc sql</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Partition-by-equivalent-in-SAS-base-or-proc-sql/m-p/416021#M280183</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input User  ID_option  $        time   : datetime32.          usage   ;
format  time   datetime32. ;
cards; 
1         a1        12OCT2017:11:20:32       3             
1         a1        12OCT2017:10:23:24       7             
1         b1        12OCT2017:09:34:55       12            
2         b1        12OCT2017:08:55:06       4             
1         a1        12OCT2017:07:59:53       7             
2         b1        12OCT2017:06:59:12       2             
;
run;
proc sql;
select *,(select sum(usage) from have as b where b.user=a.user and b.ID_option=a.ID_option and
b.time between a.time-3*3600 and a.time ) as want
 from have as a;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 24 Nov 2017 13:39:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Partition-by-equivalent-in-SAS-base-or-proc-sql/m-p/416021#M280183</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2017-11-24T13:39:45Z</dc:date>
    </item>
    <item>
      <title>Re: Partition by equivalent in SAS base or proc sql</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Partition-by-equivalent-in-SAS-base-or-proc-sql/m-p/416355#M280184</link>
      <description>&lt;P&gt;I'm testing this code now, but it works about 1 hour, and still counting, I don't know why,&amp;nbsp;it looks good.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Maybe there is need for some sorting data before aggregation?&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you for your reply.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 27 Nov 2017 12:34:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Partition-by-equivalent-in-SAS-base-or-proc-sql/m-p/416355#M280184</guid>
      <dc:creator>jovic92</dc:creator>
      <dc:date>2017-11-27T12:34:49Z</dc:date>
    </item>
    <item>
      <title>Re: Partition by equivalent in SAS base or proc sql</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Partition-by-equivalent-in-SAS-base-or-proc-sql/m-p/416360#M280185</link>
      <description>&lt;P&gt;Do you have a big table ? If you have, then I suggest to split your big table into many small table, each contains only ONE id . and run my code . Or maybe you need other fast algorithm like Hash Table .&lt;/P&gt;</description>
      <pubDate>Mon, 27 Nov 2017 12:50:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Partition-by-equivalent-in-SAS-base-or-proc-sql/m-p/416360#M280185</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2017-11-27T12:50:09Z</dc:date>
    </item>
    <item>
      <title>Re: Partition by equivalent in SAS base or proc sql</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Partition-by-equivalent-in-SAS-base-or-proc-sql/m-p/416362#M280186</link>
      <description>&lt;P&gt;Yes, it is a big table, but I think it should be done till now. I will try that, thanks.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 27 Nov 2017 12:52:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Partition-by-equivalent-in-SAS-base-or-proc-sql/m-p/416362#M280186</guid>
      <dc:creator>jovic92</dc:creator>
      <dc:date>2017-11-27T12:52:13Z</dc:date>
    </item>
    <item>
      <title>Re: Partition by equivalent in SAS base or proc sql</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Partition-by-equivalent-in-SAS-base-or-proc-sql/m-p/416367#M280187</link>
      <description>&lt;P&gt;Now I've made table a smaller, I've take just 5 of 24 loader files and still have the same problem.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 27 Nov 2017 13:06:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Partition-by-equivalent-in-SAS-base-or-proc-sql/m-p/416367#M280187</guid>
      <dc:creator>jovic92</dc:creator>
      <dc:date>2017-11-27T13:06:15Z</dc:date>
    </item>
    <item>
      <title>Re: Partition by equivalent in SAS base or proc sql</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Partition-by-equivalent-in-SAS-base-or-proc-sql/m-p/416378#M280188</link>
      <description>&lt;P&gt;OK. Here is . Hope you have big enough memory to run Hash Table.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input User  ID_option  $        time   : datetime32.          usage   ;
format  time   datetime32. ;
cards; 
1         a1        12OCT2017:11:20:32       3             
1         a1        12OCT2017:10:23:24       7             
1         b1        12OCT2017:09:34:55       12            
2         b1        12OCT2017:08:55:06       4             
1         a1        12OCT2017:07:59:53       7             
2         b1        12OCT2017:06:59:12       2             
;
run;
data want;
 if _n_=1 then do;
  if 0 then set have(rename=(usage=_usage));
  declare hash h(dataset:'have(rename=(usage=_usage))',hashexp:20);
  h.definekey('user','id_option','time');
  h.definedata('_usage');
  h.definedone();
 end;
set have;
sum_usage_3hr=0;
do i=time-3*3600 to time ;
 if h.find(key:user,key:id_option,key:i)=0 then sum_usage_3hr+_usage;
end;
drop _usage i;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 27 Nov 2017 13:31:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Partition-by-equivalent-in-SAS-base-or-proc-sql/m-p/416378#M280188</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2017-11-27T13:31:08Z</dc:date>
    </item>
    <item>
      <title>Re: Partition by equivalent in SAS base or proc sql</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Partition-by-equivalent-in-SAS-base-or-proc-sql/m-p/416382#M280189</link>
      <description>&lt;P&gt;And don't forget round your TIME variable, if it has decimal number.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input User  ID_option  $        time   : datetime32.          usage   ;
time=int(time);
format  time   datetime32. ;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 27 Nov 2017 13:33:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Partition-by-equivalent-in-SAS-base-or-proc-sql/m-p/416382#M280189</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2017-11-27T13:33:41Z</dc:date>
    </item>
    <item>
      <title>Re: Partition by equivalent in SAS base or proc sql</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Partition-by-equivalent-in-SAS-base-or-proc-sql/m-p/416383#M280190</link>
      <description>&lt;P&gt;Time is in format I have posted in question.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you, I'm going to try that in a few minutes.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 27 Nov 2017 13:36:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Partition-by-equivalent-in-SAS-base-or-proc-sql/m-p/416383#M280190</guid>
      <dc:creator>jovic92</dc:creator>
      <dc:date>2017-11-27T13:36:01Z</dc:date>
    </item>
    <item>
      <title>Re: Partition by equivalent in SAS base or proc sql</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Partition-by-equivalent-in-SAS-base-or-proc-sql/m-p/416402#M280191</link>
      <description>&lt;P&gt;I have got an error:&amp;nbsp;&lt;/P&gt;&lt;P&gt;Invalid DO loop control information, either the INITIAL or TO expression is missing or the BY expression is missing, zero, or invalid.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 27 Nov 2017 14:17:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Partition-by-equivalent-in-SAS-base-or-proc-sql/m-p/416402#M280191</guid>
      <dc:creator>jovic92</dc:creator>
      <dc:date>2017-11-27T14:17:37Z</dc:date>
    </item>
    <item>
      <title>Re: Partition by equivalent in SAS base or proc sql</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Partition-by-equivalent-in-SAS-base-or-proc-sql/m-p/416406#M280192</link>
      <description>&lt;P&gt;If you don't have big memory to run Hash Table, Try this one .&lt;/P&gt;
&lt;P&gt;NOTE: these code is assuming there are not duplicate TIME for the same user and id_option.&lt;/P&gt;
&lt;P&gt;If there duplicated TIME(e.g.&amp;nbsp; two or more obs have the same TIME under the same user and same id_option),&lt;/P&gt;
&lt;P&gt;use PROC SUMMARY to sum USAGE.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input User  ID_option  $        time   : datetime32.          usage   ;
format  time   datetime32. ;
cards; 
1         a1        12OCT2017:11:20:32       3             
1         a1        12OCT2017:10:23:24       7             
1         b1        12OCT2017:09:34:55       12            
2         b1        12OCT2017:08:55:06       4             
1         a1        12OCT2017:07:59:53       7             
2         b1        12OCT2017:06:59:12       2             
;
run;
proc sort data=have;
by User  ID_option ;
run;
data want;
 if _n_=1 then do;
  if 0 then set have;
  declare hash h(hashexp:20);
  h.definekey('user','id_option','time');
  h.definedata('_usage');
  h.definedone();
 end;

do until(last.id_option);
set have;
by user id_option;
 _usage=usage;
 h.ref();
end;

do until(last.id_option);
set have;
by user id_option;
sum_usage_3hr=0;
do i=time-3*3600 to time ;
 if h.find(key:user,key:id_option,key:i)=0 then sum_usage_3hr+_usage;
end;
output;
end;
h.clear();
drop _usage i;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 27 Nov 2017 14:28:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Partition-by-equivalent-in-SAS-base-or-proc-sql/m-p/416406#M280192</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2017-11-27T14:28:05Z</dc:date>
    </item>
    <item>
      <title>Re: Partition by equivalent in SAS base or proc sql</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Partition-by-equivalent-in-SAS-base-or-proc-sql/m-p/416410#M280193</link>
      <description>&lt;P&gt;I think I have enough memory, 32 GB RAM an 8-core processor.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Just don't get it why is there problem with "No mathing DO/SELECT statement now.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm going to try new code.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 27 Nov 2017 14:34:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Partition-by-equivalent-in-SAS-base-or-proc-sql/m-p/416410#M280193</guid>
      <dc:creator>jovic92</dc:creator>
      <dc:date>2017-11-27T14:34:33Z</dc:date>
    </item>
    <item>
      <title>Re: Partition by equivalent in SAS base or proc sql</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Partition-by-equivalent-in-SAS-base-or-proc-sql/m-p/416412#M280194</link>
      <description>&lt;P&gt;NOTE: If you have duplicated obs , you need run PROC SUMMARY firstly&amp;nbsp;&lt;/P&gt;
&lt;P&gt;i.e.&lt;/P&gt;
&lt;P&gt;1 a1 12OCT2017:11:20:32 3 &lt;BR /&gt;1 a1 &lt;STRONG&gt;12OCT2017:10:23:24&lt;/STRONG&gt; 7&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;1 a1 &lt;STRONG&gt;12OCT2017:10:23:24&lt;/STRONG&gt; 2&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;1 a1 &lt;STRONG&gt;12OCT2017:10:23:24&lt;/STRONG&gt; 4&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;proc summary data=have;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;by&amp;nbsp;&amp;nbsp;User&amp;nbsp; ID_option&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;time ;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;var usage;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;output out=have1 sum=;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;run;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 27 Nov 2017 14:39:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Partition-by-equivalent-in-SAS-base-or-proc-sql/m-p/416412#M280194</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2017-11-27T14:39:23Z</dc:date>
    </item>
    <item>
      <title>Re: Partition by equivalent in SAS base or proc sql</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Partition-by-equivalent-in-SAS-base-or-proc-sql/m-p/416419#M280195</link>
      <description>&lt;P&gt;I have done that, but again is the problem with DO loop control. Same as I mentioned earlier.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I appreciate&amp;nbsp;your help, either we find the solution or not.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 27 Nov 2017 14:54:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Partition-by-equivalent-in-SAS-base-or-proc-sql/m-p/416419#M280195</guid>
      <dc:creator>jovic92</dc:creator>
      <dc:date>2017-11-27T14:54:44Z</dc:date>
    </item>
    <item>
      <title>Re: Partition by equivalent in SAS base or proc sql</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Partition-by-equivalent-in-SAS-base-or-proc-sql/m-p/416658#M280196</link>
      <description>&lt;P&gt;It is really weird. I didn't run into any ERROR when running my code . Can you post your LOG ?&lt;/P&gt;</description>
      <pubDate>Tue, 28 Nov 2017 12:44:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Partition-by-equivalent-in-SAS-base-or-proc-sql/m-p/416658#M280196</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2017-11-28T12:44:25Z</dc:date>
    </item>
    <item>
      <title>Re: Partition by equivalent in SAS base or proc sql</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Partition-by-equivalent-in-SAS-base-or-proc-sql/m-p/416662#M280197</link>
      <description>&lt;P&gt;Error : Invalid DO loop control information, either the INITIAL or TO expression is missing or the BY expression is missing, zero, or invalid.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;NOTE: Missing values were generated as a result of performing an operation on missing values.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a few rows of missing values in Usage and Time columns in this dataset(whole dataset has about milion rows), I assume that causes the problem?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 28 Nov 2017 12:53:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Partition-by-equivalent-in-SAS-base-or-proc-sql/m-p/416662#M280197</guid>
      <dc:creator>jovic92</dc:creator>
      <dc:date>2017-11-28T12:53:22Z</dc:date>
    </item>
    <item>
      <title>Re: Partition by equivalent in SAS base or proc sql</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Partition-by-equivalent-in-SAS-base-or-proc-sql/m-p/416671#M280198</link>
      <description>&lt;P&gt;Yeah. That is saying you have missing value for TIME variable ,just add one more condition.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
 if _n_=1 then do;
  if 0 then set have(rename=(usage=_usage));
  declare hash h(dataset:'have(&lt;STRONG&gt;where=(time is not missing)&lt;/STRONG&gt; rename=(usage=_usage))',hashexp:20);
  h.definekey('user','id_option','time');
  h.definedata('_usage');
  h.definedone();
 end;
set have;
sum_usage_3hr=0;

&lt;STRONG&gt;if not missing(time) then do;&lt;/STRONG&gt;
do i=time-3*3600 to time ;
 if h.find(key:user,key:id_option,key:i)=0 then sum_usage_3hr+_usage;
end;
&lt;STRONG&gt;end;&lt;/STRONG&gt;

drop _usage i;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 28 Nov 2017 13:12:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Partition-by-equivalent-in-SAS-base-or-proc-sql/m-p/416671#M280198</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2017-11-28T13:12:34Z</dc:date>
    </item>
    <item>
      <title>Re: Partition by equivalent in SAS base or proc sql</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Partition-by-equivalent-in-SAS-base-or-proc-sql/m-p/416697#M280199</link>
      <description>&lt;P&gt;Now it's all zeros in SUM_USAGE_3HR. Can it be a problem if it's TIME stored as a string or as a integer?&amp;nbsp;&lt;/P&gt;&lt;P&gt;When I wrote a program for loading data (after that, and before this step I had a few filtering and join) in input I include: TIME&amp;nbsp;&lt;SPAN&gt;anydtdtm23.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 28 Nov 2017 14:16:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Partition-by-equivalent-in-SAS-base-or-proc-sql/m-p/416697#M280199</guid>
      <dc:creator>jovic92</dc:creator>
      <dc:date>2017-11-28T14:16:47Z</dc:date>
    </item>
    <item>
      <title>Re: Partition by equivalent in SAS base or proc sql</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Partition-by-equivalent-in-SAS-base-or-proc-sql/m-p/417001#M280200</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/179286"&gt;@jovic92&lt;/a&gt;: If your data is sorted, you can use the SET statement with POINT= to calculate rolling sums:&lt;/P&gt;&lt;PRE&gt;proc sort data=have;
  by User ID_option time;
run;

data want;
  set have;
  by User ID_option ;
  if first.ID_option then do;
    _Pstart=_N_;
    _start=time;
    sum=usage;
    end;
  else do;
    sum+usage;
    do _Pstart=_Pstart to _N_;
      set have(keep=time usage rename=(time=_start usage=_subtract)) point=_Pstart;
      if _start&amp;gt;=intnx('second', time, -3*3600) then
        leave;
      sum+-_subtract;
      end;
    end;
  drop _:;
run;&lt;/PRE&gt;</description>
      <pubDate>Wed, 29 Nov 2017 09:58:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Partition-by-equivalent-in-SAS-base-or-proc-sql/m-p/417001#M280200</guid>
      <dc:creator>s_lassen</dc:creator>
      <dc:date>2017-11-29T09:58:26Z</dc:date>
    </item>
    <item>
      <title>Re: Partition by equivalent in SAS base or proc sql</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Partition-by-equivalent-in-SAS-base-or-proc-sql/m-p/417029#M280201</link>
      <description>&lt;P&gt;"&lt;SPAN&gt;Now it's all zeros in SUM_USAGE_3HR. Can it be a problem if it's TIME stored as a string or as a integer? "&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;I doubted your TIME is not real integer, it should have decimal number.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Therefore Hash Table can correctly find the right TIME.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;use int() to make TIME is integer as I said before.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;TIME=int(TIME);&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 29 Nov 2017 12:41:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Partition-by-equivalent-in-SAS-base-or-proc-sql/m-p/417029#M280201</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2017-11-29T12:41:08Z</dc:date>
    </item>
  </channel>
</rss>

