<?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 do i group interval by time and do calculation based on ID and class in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/how-do-i-group-interval-by-time-and-do-calculation-based-on-ID/m-p/411939#M279772</link>
    <description>&lt;P&gt;That is weird. Your table name is PEOPLE ? and it is in WORK libarary ?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
set people  ;

retain _time ;
format time _time time8.;
if _n_=1 then _time=time;
if time &amp;gt; _time+20*60 then do;group+1;_time=_time+20*60;end;
run;

proc sql;
.............&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Thu, 09 Nov 2017 14:17:47 GMT</pubDate>
    <dc:creator>Ksharp</dc:creator>
    <dc:date>2017-11-09T14:17:47Z</dc:date>
    <item>
      <title>how do i group interval by time and do calculation based on ID and class</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-do-i-group-interval-by-time-and-do-calculation-based-on-ID/m-p/411885#M279759</link>
      <description>&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;TIME&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;X&lt;/TD&gt;&lt;TD&gt;Y&lt;/TD&gt;&lt;TD&gt;class&lt;/TD&gt;&lt;TD&gt;ID&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;16:00:06&lt;/TD&gt;&lt;TD&gt;103.785&lt;/TD&gt;&lt;TD&gt;71.45633&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;A&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;16:05:06&l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D&gt;2&lt;/TD&gt;&lt;TD&gt;U7&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;18:25:12&lt;/TD&gt;&lt;TD&gt;104.7226&lt;/TD&gt;&lt;TD&gt;90.43502&lt;/TD&gt;&lt;TD&gt;3&lt;/TD&gt;&lt;TD&gt;S&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;18:30:05&lt;/TD&gt;&lt;TD&gt;109.6942&lt;/TD&gt;&lt;TD&gt;66.22699&lt;/TD&gt;&lt;TD&gt;3&lt;/TD&gt;&lt;TD&gt;S33&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;18:33:04&lt;/TD&gt;&lt;TD&gt;109.7128&lt;/TD&gt;&lt;TD&gt;97.24288&lt;/TD&gt;&lt;TD&gt;3&lt;/TD&gt;&lt;TD&gt;T17&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;18:40:44&lt;/TD&gt;&lt;TD&gt;56.12425&lt;/TD&gt;&lt;TD&gt;71.13522&lt;/TD&gt;&lt;TD&gt;3&lt;/TD&gt;&lt;TD&gt;G22&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;18:44:02&lt;/TD&gt;&lt;TD&gt;93.29675&lt;/TD&gt;&lt;TD&gt;63.89221&lt;/TD&gt;&lt;TD&gt;3&lt;/TD&gt;&lt;TD&gt;II1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;18:50:13&lt;/TD&gt;&lt;TD&gt;109.7023&lt;/TD&gt;&lt;TD&gt;71.47756&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;S9&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;PRE class="lang-py prettyprint prettyprinted"&gt;&lt;CODE&gt;&lt;SPAN class="pln"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;1- Above is a sample of a data frame which has thousands of records.&lt;/P&gt;&lt;P&gt;2- How can group it by the time (20 min) and class number. Then calculate the Euclidean distance between x, y using :&lt;/P&gt;&lt;PRE class="lang-py prettyprint prettyprinted"&gt;&lt;CODE&gt;&lt;SPAN class="pln"&gt;dist &lt;/SPAN&gt;&lt;SPAN class="pun"&gt;=&lt;/SPAN&gt;&lt;SPAN class="pln"&gt; sqrt&lt;/SPAN&gt;&lt;SPAN class="pun"&gt;(&lt;/SPAN&gt; &lt;SPAN class="pun"&gt;(&lt;/SPAN&gt;&lt;SPAN class="pln"&gt;x2 &lt;/SPAN&gt;&lt;SPAN class="pun"&gt;-&lt;/SPAN&gt;&lt;SPAN class="pln"&gt; x1&lt;/SPAN&gt;&lt;SPAN class="pun"&gt;)**&lt;/SPAN&gt;&lt;SPAN class="lit"&gt;2&lt;/SPAN&gt; &lt;SPAN class="pun"&gt;+&lt;/SPAN&gt; &lt;SPAN class="pun"&gt;(&lt;/SPAN&gt;&lt;SPAN class="pln"&gt;y2 &lt;/SPAN&gt;&lt;SPAN class="pun"&gt;-&lt;/SPAN&gt;&lt;SPAN class="pln"&gt; y1&lt;/SPAN&gt;&lt;SPAN class="pun"&gt;)**&lt;/SPAN&gt;&lt;SPAN class="lit"&gt;2&lt;/SPAN&gt; &lt;SPAN class="pun"&gt;)&lt;BR /&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;3- An iteration of every 20 min for all data, no value duplicates in the single iteration. I have tried to implement this sample. but still not working.&lt;/P&gt;&lt;PRE class="lang-py prettyprint prettyprinted"&gt;&lt;CODE&gt;&lt;SPAN class="typ"&gt;The&lt;/SPAN&gt;&lt;SPAN class="pln"&gt; expected results &lt;/SPAN&gt;&lt;SPAN class="kwd"&gt;for&lt;/SPAN&gt;&lt;SPAN class="pln"&gt; the &lt;/SPAN&gt;&lt;SPAN class="lit"&gt;20min&lt;/SPAN&gt; &lt;SPAN class="kwd"&gt;in&lt;/SPAN&gt;&lt;SPAN class="pln"&gt; two iteration&lt;/SPAN&gt;&lt;SPAN class="pun"&gt;:&lt;/SPAN&gt; 

&lt;SPAN class="pln"&gt;ID  CLASS  distnace &lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN class="pln"&gt;A&lt;/SPAN&gt;&lt;SPAN class="pun"&gt;,&lt;/SPAN&gt;&lt;SPAN class="pln"&gt;A6    &lt;/SPAN&gt;&lt;SPAN class="lit"&gt;1&lt;/SPAN&gt;   &lt;SPAN class="lit"&gt;4.22695&lt;/SPAN&gt;
&lt;SPAN class="pln"&gt;A&lt;/SPAN&gt;&lt;SPAN class="pun"&gt;,&lt;/SPAN&gt;&lt;SPAN class="pln"&gt;C55   &lt;/SPAN&gt;&lt;SPAN class="lit"&gt;1&lt;/SPAN&gt;   &lt;SPAN class="lit"&gt;0.024806&lt;/SPAN&gt;
&lt;SPAN class="pln"&gt;A6&lt;/SPAN&gt;&lt;SPAN class="pun"&gt;,&lt;/SPAN&gt;&lt;SPAN class="pln"&gt; C55 &lt;/SPAN&gt;&lt;SPAN class="lit"&gt;1&lt;/SPAN&gt;   &lt;SPAN class="lit"&gt;4.251038&lt;/SPAN&gt;
&lt;SPAN class="pln"&gt;A2&lt;/SPAN&gt;&lt;SPAN class="pun"&gt;,&lt;/SPAN&gt;&lt;SPAN class="pln"&gt;O8   &lt;/SPAN&gt;&lt;SPAN class="lit"&gt;2&lt;/SPAN&gt;   &lt;SPAN class="lit"&gt;6.485861&lt;/SPAN&gt;
&lt;SPAN class="pln"&gt;A2&lt;/SPAN&gt;&lt;SPAN class="pun"&gt;,&lt;/SPAN&gt;&lt;SPAN class="pln"&gt;H77  &lt;/SPAN&gt;&lt;SPAN class="lit"&gt;2&lt;/SPAN&gt;   &lt;SPAN class="lit"&gt;22.030843&lt;/SPAN&gt;
&lt;SPAN class="pln"&gt;O8&lt;/SPAN&gt;&lt;SPAN class="pun"&gt;,&lt;/SPAN&gt;&lt;SPAN class="pln"&gt;H77  &lt;/SPAN&gt;&lt;SPAN class="lit"&gt;2&lt;/SPAN&gt;   &lt;SPAN class="lit"&gt;16.207033&lt;/SPAN&gt;
&lt;SPAN class="pln"&gt;F4&lt;/SPAN&gt;&lt;SPAN class="pun"&gt;,&lt;/SPAN&gt;&lt;SPAN class="pln"&gt; E4  &lt;/SPAN&gt;&lt;SPAN class="lit"&gt;3&lt;/SPAN&gt;   &lt;SPAN class="lit"&gt;4.4506&lt;/SPAN&gt;
&lt;SPAN class="pln"&gt;A&lt;/SPAN&gt;&lt;SPAN class="pun"&gt;,&lt;/SPAN&gt;&lt;SPAN class="pln"&gt;A6    &lt;/SPAN&gt;&lt;SPAN class="lit"&gt;1&lt;/SPAN&gt;   &lt;SPAN class="lit"&gt;17.279585&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 09 Nov 2017 12:04:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-do-i-group-interval-by-time-and-do-calculation-based-on-ID/m-p/411885#M279759</guid>
      <dc:creator>ihlayyel</dc:creator>
      <dc:date>2017-11-09T12:04:05Z</dc:date>
    </item>
    <item>
      <title>Re: how do i group interval by time and do calculation based on ID and class</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-do-i-group-interval-by-time-and-do-calculation-based-on-ID/m-p/411892#M279760</link>
      <description>&lt;P&gt;Since SAS time (and datetime) values are counts of seconds, you can normalize them to 20-minute frames by doing&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;tim20 = int(time / 1200) * 1200;
format tim20 time8.;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;and then use that in your by statement(s).&lt;/P&gt;</description>
      <pubDate>Thu, 09 Nov 2017 12:25:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-do-i-group-interval-by-time-and-do-calculation-based-on-ID/m-p/411892#M279760</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2017-11-09T12:25:07Z</dc:date>
    </item>
    <item>
      <title>Re: how do i group interval by time and do calculation based on ID and class</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-do-i-group-interval-by-time-and-do-calculation-based-on-ID/m-p/411896#M279761</link>
      <description>&lt;P&gt;You can create groups based on intervals 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 TIME:time8. X Y class ID$;
format time time8.;
datalines;
16:00:06 103.785 71.45633 1 A 
16:05:06 109.095 92.82449 2 A2 
16:08:06 105.981 67.84456 1 A6 
16:11:05 103.461 71.42452 3 F4 
16:15:05 103.7674 71.47382 1 C55 
16:17:26 107.4762 73.3445 3 E4 
16:18:06 105.2773 87.58118 2 O8 
16:19:21 103.7858 71.44293 2 H77 
16:33:18 103.7201 71.37974 3 XX 
16:40:11 107.3432 88.27521 3 X8 
17:43:06 100.8496 67.38097 2 D 
17:45:06 110.1006 66.26799 2 A 
17:50:12 105.8542 87.77079 2 D4 
17:55:09 96.14285 61.99789 2 F4 
18:02:08 103.7829 71.48327 2 RR3 
18:09:33 103.9275 71.49321 2 U7 
18:25:12 104.7226 90.43502 3 S 
18:30:05 109.6942 66.22699 3 S33 
18:33:04 109.7128 97.24288 3 T17 
18:40:44 56.12425 71.13522 3 G22 
18:44:02 93.29675 63.89221 3 II1 
18:50:13 109.7023 71.47756 1 S9 
;

data grouped;
	set have;
	interval= intck('minute20', '16:00:00't, time)+1;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Regarding your desired output.. I don't understand why the Euclidian distance between A and A6&amp;nbsp;for Class 1 appears twice?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 09 Nov 2017 12:36:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-do-i-group-interval-by-time-and-do-calculation-based-on-ID/m-p/411896#M279761</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2017-11-09T12:36:39Z</dc:date>
    </item>
    <item>
      <title>Re: how do i group interval by time and do calculation based on ID and class</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-do-i-group-interval-by-time-and-do-calculation-based-on-ID/m-p/411897#M279762</link>
      <description>the output is for 2 iteration.kinldy look at the time itration 1 = 16:00:06 to 16:19:21 iteration2 = 16:33:18 to 16:40:11</description>
      <pubDate>Thu, 09 Nov 2017 12:42:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-do-i-group-interval-by-time-and-do-calculation-based-on-ID/m-p/411897#M279762</guid>
      <dc:creator>ihlayyel</dc:creator>
      <dc:date>2017-11-09T12:42:26Z</dc:date>
    </item>
    <item>
      <title>Re: how do i group interval by time and do calculation based on ID and class</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-do-i-group-interval-by-time-and-do-calculation-based-on-ID/m-p/411898#M279763</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
infile cards expandtabs;
input TIME $ 	X	Y	class	ID $;
cards;
16:00:06	103.785	71.45633	1	A
16:05:06	109.095	92.82449	2	A2
16:08:06	105.981	67.84456	1	A6
16:11:05	103.461	71.42452	3	F4
16:15:05	103.7674	71.47382	1	C55
16:17:26	107.4762	73.3445	3	E4
16:18:06	105.2773	87.58118	2	O8
16:19:21	103.7858	71.44293	2	H77
16:33:18	103.7201	71.37974	3	XX
16:40:11	107.3432	88.27521	3	X8
17:43:06	100.8496	67.38097	2	D
17:45:06	110.1006	66.26799	2	A
17:50:12	105.8542	87.77079	2	D4
17:55:09	96.14285	61.99789	2	F4
18:02:08	103.7829	71.48327	2	RR3
18:09:33	103.9275	71.49321	2	U7
18:25:12	104.7226	90.43502	3	S
18:30:05	109.6942	66.22699	3	S33
18:33:04	109.7128	97.24288	3	T17
18:40:44	56.12425	71.13522	3	G22
18:44:02	93.29675	63.89221	3	II1
18:50:13	109.7023	71.47756	1	S9
;
run;
proc sql;
create table want as
 select  catx(',',a.id,b.id) as id,Euclid(a.x-b.x,a.y-b.y) as distance
  from have as a,have as b
   where a.class=b.class and a.id ne b.id ;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 09 Nov 2017 12:46:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-do-i-group-interval-by-time-and-do-calculation-based-on-ID/m-p/411898#M279763</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2017-11-09T12:46:28Z</dc:date>
    </item>
    <item>
      <title>Re: how do i group interval by time and do calculation based on ID and class</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-do-i-group-interval-by-time-and-do-calculation-based-on-ID/m-p/411903#M279764</link>
      <description>That is nice, thank you so much. but have you consider the time interval?</description>
      <pubDate>Thu, 09 Nov 2017 12:54:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-do-i-group-interval-by-time-and-do-calculation-based-on-ID/m-p/411903#M279764</guid>
      <dc:creator>ihlayyel</dc:creator>
      <dc:date>2017-11-09T12:54:56Z</dc:date>
    </item>
    <item>
      <title>Re: how do i group interval by time and do calculation based on ID and class</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-do-i-group-interval-by-time-and-do-calculation-based-on-ID/m-p/411911#M279765</link>
      <description>&lt;P&gt;OK. No problem.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
infile cards expandtabs;
input TIME : time8.	X	Y	class	ID $;
retain _time ;
format time _time time8.;
if _n_=1 then _time=time;
if time &amp;gt; _time+20*60 then do;group+1;_time=_time+20*60;end;
cards;
16:00:06	103.785	71.45633	1	A
16:05:06	109.095	92.82449	2	A2
16:08:06	105.981	67.84456	1	A6
16:11:05	103.461	71.42452	3	F4
16:15:05	103.7674	71.47382	1	C55
16:17:26	107.4762	73.3445	3	E4
16:18:06	105.2773	87.58118	2	O8
16:19:21	103.7858	71.44293	2	H77
16:33:18	103.7201	71.37974	3	XX
16:40:11	107.3432	88.27521	3	X8
17:43:06	100.8496	67.38097	2	D
17:45:06	110.1006	66.26799	2	A
17:50:12	105.8542	87.77079	2	D4
17:55:09	96.14285	61.99789	2	F4
18:02:08	103.7829	71.48327	2	RR3
18:09:33	103.9275	71.49321	2	U7
18:25:12	104.7226	90.43502	3	S
18:30:05	109.6942	66.22699	3	S33
18:33:04	109.7128	97.24288	3	T17
18:40:44	56.12425	71.13522	3	G22
18:44:02	93.29675	63.89221	3	II1
18:50:13	109.7023	71.47756	1	S9
;
run;
proc sql;
create table want as
 select  catx(',',a.id,b.id) as id,a.class as class,Euclid(a.x-b.x,a.y-b.y) as distance
  from have as a,have as b
   where a.class=b.class and a.group=b.group and a.id ne b.id ;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 09 Nov 2017 13:14:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-do-i-group-interval-by-time-and-do-calculation-based-on-ID/m-p/411911#M279765</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2017-11-09T13:14:20Z</dc:date>
    </item>
    <item>
      <title>Re: how do i group interval by time and do calculation based on ID and class</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-do-i-group-interval-by-time-and-do-calculation-based-on-ID/m-p/411917#M279766</link>
      <description>That is awesome. but iam facing a small issue here. iam reading data from csv file. so the code will be like that ?&lt;BR /&gt;&lt;BR /&gt;data work.people;&lt;BR /&gt;if _n_=1 then _time=time;&lt;BR /&gt;if time &amp;gt; _time+20*60 then do;group+1;_time=_time+20*60;&lt;BR /&gt;end;&lt;BR /&gt;run;&lt;BR /&gt;&lt;BR /&gt;proc sql;&lt;BR /&gt;create table want as&lt;BR /&gt;select catx(',',a.id,b.id) as id,a.class as class,Euclid(a.x-b.x,a.y-b.y) as distance&lt;BR /&gt;from have as a,have as b&lt;BR /&gt;where a.class=b.class and a.group=b.group and a.id ne b.id ;&lt;BR /&gt;quit;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Thu, 09 Nov 2017 13:28:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-do-i-group-interval-by-time-and-do-calculation-based-on-ID/m-p/411917#M279766</guid>
      <dc:creator>ihlayyel</dc:creator>
      <dc:date>2017-11-09T13:28:14Z</dc:date>
    </item>
    <item>
      <title>Re: how do i group interval by time and do calculation based on ID and class</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-do-i-group-interval-by-time-and-do-calculation-based-on-ID/m-p/411920#M279767</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc import datafile='c:\temp\x.csv' out=have dbms=csv replace;
guessingrows=32767;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The code above could import csv file . and check if TIME variable is numeric variable and have TIME. format .&lt;/P&gt;</description>
      <pubDate>Thu, 09 Nov 2017 13:43:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-do-i-group-interval-by-time-and-do-calculation-based-on-ID/m-p/411920#M279767</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2017-11-09T13:43:18Z</dc:date>
    </item>
    <item>
      <title>Re: how do i group interval by time and do calculation based on ID and class</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-do-i-group-interval-by-time-and-do-calculation-based-on-ID/m-p/411922#M279768</link>
      <description>&lt;P&gt;Or use data step.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
infile 'c:\temp\x.csv' truncover dsd;
input TIME : time8.	X	Y	class	ID : $40.;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 09 Nov 2017 13:45:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-do-i-group-interval-by-time-and-do-calculation-based-on-ID/m-p/411922#M279768</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2017-11-09T13:45:41Z</dc:date>
    </item>
    <item>
      <title>Re: how do i group interval by time and do calculation based on ID and class</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-do-i-group-interval-by-time-and-do-calculation-based-on-ID/m-p/411926#M279769</link>
      <description>I think you didn't get my point. I have import the data into sas. so when i call the data using this. it returns empty cell.&lt;BR /&gt;&lt;BR /&gt;data work.people;&lt;BR /&gt;if _n_=1 then _time=time;&lt;BR /&gt;if time &amp;gt; _time+20*60 then do;group+1;_time=_time+20*60;&lt;BR /&gt;end;&lt;BR /&gt;run;&lt;BR /&gt;</description>
      <pubDate>Thu, 09 Nov 2017 13:55:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-do-i-group-interval-by-time-and-do-calculation-based-on-ID/m-p/411926#M279769</guid>
      <dc:creator>ihlayyel</dc:creator>
      <dc:date>2017-11-09T13:55:57Z</dc:date>
    </item>
    <item>
      <title>Re: how do i group interval by time and do calculation based on ID and class</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-do-i-group-interval-by-time-and-do-calculation-based-on-ID/m-p/411930#M279770</link>
      <description>&lt;P&gt;OK. just use SET statement to replace INFILE . And remove INPUT.&lt;/P&gt;
&lt;P&gt;Make sure time is numeric variable.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
set have;

retain _time ;
format time _time time8.;
if _n_=1 then _time=time;
if time &amp;gt; _time+20*60 then do;group+1;_time=_time+20*60;end;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp; Note: fixed&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 09 Nov 2017 14:02:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-do-i-group-interval-by-time-and-do-calculation-based-on-ID/m-p/411930#M279770</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2017-11-09T14:02:11Z</dc:date>
    </item>
    <item>
      <title>Re: how do i group interval by time and do calculation based on ID and class</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-do-i-group-interval-by-time-and-do-calculation-based-on-ID/m-p/411935#M279771</link>
      <description>i have implemented that: I got this error&lt;BR /&gt;The time format is same as the sample I provided. Do i need to change it to other format?&lt;BR /&gt;ERROR: No DATALINES or INFILE statement.</description>
      <pubDate>Thu, 09 Nov 2017 14:12:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-do-i-group-interval-by-time-and-do-calculation-based-on-ID/m-p/411935#M279771</guid>
      <dc:creator>ihlayyel</dc:creator>
      <dc:date>2017-11-09T14:12:05Z</dc:date>
    </item>
    <item>
      <title>Re: how do i group interval by time and do calculation based on ID and class</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-do-i-group-interval-by-time-and-do-calculation-based-on-ID/m-p/411939#M279772</link>
      <description>&lt;P&gt;That is weird. Your table name is PEOPLE ? and it is in WORK libarary ?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
set people  ;

retain _time ;
format time _time time8.;
if _n_=1 then _time=time;
if time &amp;gt; _time+20*60 then do;group+1;_time=_time+20*60;end;
run;

proc sql;
.............&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 09 Nov 2017 14:17:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-do-i-group-interval-by-time-and-do-calculation-based-on-ID/m-p/411939#M279772</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2017-11-09T14:17:47Z</dc:date>
    </item>
    <item>
      <title>Re: how do i group interval by time and do calculation based on ID and class</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-do-i-group-interval-by-time-and-do-calculation-based-on-ID/m-p/411958#M279773</link>
      <description>Thank you so much. the code works perfectly.&amp;nbsp;&lt;BR /&gt;when i run the code&amp;nbsp;&amp;nbsp;&lt;BR /&gt;&amp;nbsp;&lt;BR /&gt;this what I get.&amp;nbsp;&lt;BR /&gt;&amp;nbsp;&lt;BR /&gt;78 where a.floor=b.floor and a.uid ne b.uid ;&lt;BR /&gt;ERROR: Insufficient space in file WORK.WANT.DATA.&lt;BR /&gt;ERROR: File WORK.WANT.DATA is damaged. I/O processing did not complete.&lt;BR /&gt;&amp;nbsp;&lt;BR /&gt;NOTE: PROC SQL set option NOEXEC and will continue to check the syntax of statements.&lt;BR /&gt;79 quit;&lt;BR /&gt;NOTE: The SAS System stopped processing this step because of errors.&lt;BR /&gt;NOTE: PROCEDURE SQL used (Total process time):&lt;BR /&gt;&amp;nbsp;&lt;BR /&gt;the total number of my data is 1048576 .&amp;nbsp; Do you have any suggestion for that?&amp;nbsp;&lt;BR /&gt;I really appreciate your help .&amp;nbsp;&lt;BR /&gt;Thank you&amp;nbsp;</description>
      <pubDate>Thu, 09 Nov 2017 15:00:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-do-i-group-interval-by-time-and-do-calculation-based-on-ID/m-p/411958#M279773</guid>
      <dc:creator>ihlayyel</dc:creator>
      <dc:date>2017-11-09T15:00:47Z</dc:date>
    </item>
    <item>
      <title>Re: how do i group interval by time and do calculation based on ID and class</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-do-i-group-interval-by-time-and-do-calculation-based-on-ID/m-p/411959#M279774</link>
      <description>&lt;P&gt;You're "simply" running out of space in the WORK library. First step: clean up yourself. Either remove unneeded datasets from WORK, or restart SAS altogether (that removes the WORK library physically).&lt;/P&gt;
&lt;P&gt;If that does not remedy your problem, consider increasing available space in WORK, or at least use another library for your source and target datasets that resides on other storage.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;PRC SQL does build a very large utility file while working, which might be the cause for your problem; since you get the error when writing the result dataset, at least building the utility file seems to have worked.&lt;/P&gt;</description>
      <pubDate>Thu, 09 Nov 2017 15:07:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-do-i-group-interval-by-time-and-do-calculation-based-on-ID/m-p/411959#M279774</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2017-11-09T15:07:43Z</dc:date>
    </item>
    <item>
      <title>Re: how do i group interval by time and do calculation based on ID and class</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-do-i-group-interval-by-time-and-do-calculation-based-on-ID/m-p/412230#M279775</link>
      <description>Hello, when i run the code the time function its not working. In data have&amp;gt;&amp;gt; it return all the groups 0 value.&lt;BR /&gt;if time &amp;gt; _time+20*60 then do;group+1;_time=_time+20*60;end;&lt;BR /&gt;&lt;BR /&gt;could u please check that again ?</description>
      <pubDate>Fri, 10 Nov 2017 06:49:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-do-i-group-interval-by-time-and-do-calculation-based-on-ID/m-p/412230#M279775</guid>
      <dc:creator>ihlayyel</dc:creator>
      <dc:date>2017-11-10T06:49:04Z</dc:date>
    </item>
    <item>
      <title>Re: how do i group interval by time and do calculation based on ID and class</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-do-i-group-interval-by-time-and-do-calculation-based-on-ID/m-p/412255#M279776</link>
      <description>&lt;DIV&gt;&lt;DIV class="sasNote"&gt;I have cleaned the work library and restart it again. but it dose not work. this is the error that i got.&amp;nbsp;&lt;/DIV&gt;&lt;DIV class="sasNote"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class="sasNote"&gt;&amp;nbsp;&lt;DIV&gt;&lt;DIV class="sasNote"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class="sasNote"&gt;NOTE: There were 1048575 observations read from the data set WORK.PEOPLE.&lt;/DIV&gt;&lt;DIV class="sasNote"&gt;NOTE: The data set WORK.HAVE has 1048575 observations and 9 variables.&lt;/DIV&gt;&lt;DIV class="sasNote"&gt;NOTE: DATA statement used (Total process time):&lt;/DIV&gt;&lt;DIV class="sasNote"&gt;real time 1.18 seconds&lt;/DIV&gt;&lt;DIV class="sasNote"&gt;cpu time 0.47 seconds&lt;/DIV&gt;&lt;DIV class="sasNote"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class="sasSource"&gt;74 proc sql;&lt;/DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;DIV class="sasNote"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class="sasSource"&gt;75 create table want as&lt;/DIV&gt;&lt;DIV class="sasSource"&gt;76 select catx(',',a.uid,b.uid) as id, catx(',',a.floor,b.floor) as floor,Euclid(a.x-b.x,a.y-b.y) as distance&lt;/DIV&gt;&lt;DIV class="sasSource"&gt;77 from have as a, have as b&lt;/DIV&gt;&lt;DIV class="sasSource"&gt;78 where a.floor=b.floor and a.uid ne b.uid and a.group=b.group;&lt;/DIV&gt;&lt;DIV class="sasError"&gt;ERROR: Insufficient space in file WORK.WANT.DATA.&lt;/DIV&gt;&lt;DIV class="sasError"&gt;ERROR: File WORK.WANT.DATA is damaged. I/O processing did not complete.&lt;/DIV&gt;&lt;DIV class="sasSource"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class="sasNote"&gt;NOTE: PROC SQL set option NOEXEC and will continue to check the syntax of statements.&lt;/DIV&gt;&lt;DIV class="sasSource"&gt;79&lt;/DIV&gt;&lt;DIV class="sasSource"&gt;80 quit;&lt;/DIV&gt;&lt;DIV class="sasNote"&gt;NOTE: The SAS System stopped processing this step because of errors.&lt;/DIV&gt;&lt;DIV class="sasNote"&gt;NOTE: PROCEDURE SQL used (Total process time):&lt;/DIV&gt;&lt;DIV class="sasNote"&gt;real time 22.38 seconds&lt;/DIV&gt;&lt;DIV class="sasNote"&gt;cpu time 9.30 seconds&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;</description>
      <pubDate>Fri, 10 Nov 2017 09:48:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-do-i-group-interval-by-time-and-do-calculation-based-on-ID/m-p/412255#M279776</guid>
      <dc:creator>ihlayyel</dc:creator>
      <dc:date>2017-11-10T09:48:15Z</dc:date>
    </item>
    <item>
      <title>Re: how do i group interval by time and do calculation based on ID and class</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-do-i-group-interval-by-time-and-do-calculation-based-on-ID/m-p/412260#M279777</link>
      <description>&lt;P&gt;Create a new library that is physically on another file system, and store your have and want datasets there; then only the intermediate file(s) automatically created by proc sql need space in WORK.&lt;/P&gt;
&lt;P&gt;Or increase the size of the filesystem where WORK is located.&lt;/P&gt;</description>
      <pubDate>Fri, 10 Nov 2017 10:01:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-do-i-group-interval-by-time-and-do-calculation-based-on-ID/m-p/412260#M279777</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2017-11-10T10:01:00Z</dc:date>
    </item>
    <item>
      <title>Re: how do i group interval by time and do calculation based on ID and class</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-do-i-group-interval-by-time-and-do-calculation-based-on-ID/m-p/412292#M279778</link>
      <description>&lt;P&gt;Firstly , the code of mine is getting what you want?&lt;/P&gt;
&lt;P&gt;If it was, then your original data is not like what you posted, can you post your real data and the output of&lt;/P&gt;
&lt;P&gt;PROC CONTENTS DATA=PEOPLE;RUN:&lt;/P&gt;</description>
      <pubDate>Fri, 10 Nov 2017 12:37:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-do-i-group-interval-by-time-and-do-calculation-based-on-ID/m-p/412292#M279778</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2017-11-10T12:37:14Z</dc:date>
    </item>
  </channel>
</rss>

