<?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: Collapsing dataset while keeping other variables in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Collapsing-dataset-while-keeping-other-variables/m-p/292318#M60651</link>
    <description>&lt;P&gt;Thank you, solved it with proc sql but freq will also work!&lt;/P&gt;</description>
    <pubDate>Wed, 17 Aug 2016 23:44:12 GMT</pubDate>
    <dc:creator>MaBo1011</dc:creator>
    <dc:date>2016-08-17T23:44:12Z</dc:date>
    <item>
      <title>Collapsing dataset while keeping other variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Collapsing-dataset-while-keeping-other-variables/m-p/292073#M60563</link>
      <description>&lt;P&gt;Hello there,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to collapse (group) my data by time (seconds). Sounds easy, well, but doesn't work.&lt;/P&gt;&lt;P&gt;I assume it is because CEIL does not round to integers but that's just a guess and I tried INT without success.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Why do I still get duplicate seconds observations? (The volume variable should be summed up when collapsing.)&lt;/P&gt;&lt;P&gt;So basically: I converted milliseconds to seconds and want to bring them to unique seconds observations. So, keep all observations, collapse seconds (which are duplicate) and sum up their values in the variable "volume".&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any idea?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;data temp;
set have;
seconds = ceil(int(miliseconds/1000));
run;

proc sql; 
  create table want as
  	select *, sum(volume) as SecVolume
  	from temp
		group by seconds;
quit;run;

proc sort data=want;
by id date seconds;
run;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 17 Aug 2016 06:46:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Collapsing-dataset-while-keeping-other-variables/m-p/292073#M60563</guid>
      <dc:creator>MarcBoh</dc:creator>
      <dc:date>2016-08-17T06:46:58Z</dc:date>
    </item>
    <item>
      <title>Re: Collapsing dataset while keeping other variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Collapsing-dataset-while-keeping-other-variables/m-p/292074#M60564</link>
      <description>&lt;P&gt;Take a close look at the log of your SQL; you'll find a NOTE about remerging summary statistics.&lt;/P&gt;
&lt;P&gt;If you include columns other than the summary values and the columns used in the group by, all observations will appear in the output, and the summary results will be merged back into all of them.&lt;/P&gt;
&lt;P&gt;Your SQL should look rather like this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql; 
  create table want as
  	select id, date, seconds, sum(volume) as SecVolume
  	from temp
		group by id, date, seconds;
quit;run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 18 Aug 2016 06:20:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Collapsing-dataset-while-keeping-other-variables/m-p/292074#M60564</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2016-08-18T06:20:13Z</dc:date>
    </item>
    <item>
      <title>Re: Collapsing dataset while keeping other variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Collapsing-dataset-while-keeping-other-variables/m-p/292203#M60607</link>
      <description>&lt;P&gt;I obviously don't know where you are going with this but I would suggest creating a SAS&amp;nbsp;time valued variable. Then you can use a FORMAT that only displays to whole seconds (if I understand what your attempt at rounding is doing) for most procedures.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
data example;
   input time;
datalines;
1.1
1.2
0.003
5.02
5.04
120.23
120.45
;
run;

proc freq data=example;
   tables time;
   format time time8.;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 17 Aug 2016 14:38:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Collapsing-dataset-while-keeping-other-variables/m-p/292203#M60607</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2016-08-17T14:38:41Z</dc:date>
    </item>
    <item>
      <title>Re: Collapsing dataset while keeping other variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Collapsing-dataset-while-keeping-other-variables/m-p/292317#M60650</link>
      <description>&lt;P&gt;Works perfect, thanks again Kurt &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 17 Aug 2016 23:43:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Collapsing-dataset-while-keeping-other-variables/m-p/292317#M60650</guid>
      <dc:creator>MaBo1011</dc:creator>
      <dc:date>2016-08-17T23:43:39Z</dc:date>
    </item>
    <item>
      <title>Re: Collapsing dataset while keeping other variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Collapsing-dataset-while-keeping-other-variables/m-p/292318#M60651</link>
      <description>&lt;P&gt;Thank you, solved it with proc sql but freq will also work!&lt;/P&gt;</description>
      <pubDate>Wed, 17 Aug 2016 23:44:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Collapsing-dataset-while-keeping-other-variables/m-p/292318#M60651</guid>
      <dc:creator>MaBo1011</dc:creator>
      <dc:date>2016-08-17T23:44:12Z</dc:date>
    </item>
  </channel>
</rss>

