<?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: sort a dataset in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/sort-a-dataset/m-p/695746#M25197</link>
    <description>&lt;P&gt;Thank you! The example data is as follow.&lt;BR /&gt;Participant# Event # Time Value&lt;BR /&gt;1 1 06:45:00 23&lt;BR /&gt;1 2 06:45:00 400&lt;BR /&gt;1 3 11:00:00 300&lt;BR /&gt;1 4 11:00:00 100&lt;BR /&gt;1 5 18:00:00 500 &lt;BR /&gt;2 1 10:00:00 500&lt;BR /&gt;2 2 11:45:00 600&lt;BR /&gt;2 3 20:00:00 700&lt;/P&gt;</description>
    <pubDate>Sun, 01 Nov 2020 15:32:08 GMT</pubDate>
    <dc:creator>knighsson</dc:creator>
    <dc:date>2020-11-01T15:32:08Z</dc:date>
    <item>
      <title>sort a dataset</title>
      <link>https://communities.sas.com/t5/New-SAS-User/sort-a-dataset/m-p/695713#M25194</link>
      <description>&lt;P&gt;Hello, I want to sort my dataset. The original data looks like below:&amp;nbsp;&amp;nbsp;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Screen Shot 2020-10-31 at 23.01.52.png" style="width: 988px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/51286iCAFC898234ADD8D5/image-size/large?v=v2&amp;amp;px=999" role="button" title="Screen Shot 2020-10-31 at 23.01.52.png" alt="Screen Shot 2020-10-31 at 23.01.52.png" /&gt;&lt;/span&gt;The dataset mainly contains two kind of variables: time of the event, and event (each event has a continuous value). The "time 1" is the time of "event 1", "time 2" is the time of "event 2", and so on. "Time 1" to "time 7" a&lt;SPAN&gt;re listed in chronological order, so&amp;nbsp;&lt;/SPAN&gt;"time 1" is always earlier than or same to "time 2" because event 1 and 2, or event 2 and 3 and 4, or all 7 events could happen at the same time. Each participant could have at least 1 up to 7 events.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But I want to redesign this dataset in a summary way. I want to plus the value of the events that happened at the same time, and make a table that variables are the 24 hours. So the goal is to make a new dataset looks below:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Screen Shot 2020-10-31 at 23.02.06.png" style="width: 860px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/51287i09791649CFB0C269/image-size/large?v=v2&amp;amp;px=999" role="button" title="Screen Shot 2020-10-31 at 23.02.06.png" alt="Screen Shot 2020-10-31 at 23.02.06.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have some idea about how to do this, but I don't know how to apply my idea into SAS code.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Step 1: assign each time a continuous value: for example, "time 1" is 6:45, so "new time 1" could be 6X60+45=405, but I don't know how to assign this value on all the time of all participants.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Step 2: combine events' value together when they happened at the same time. But I don't know how to link the time and the event together.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Step 3: put the final event value under the new time variable like "6:00-7:00".&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I tried to do this, however, due to my limited knowledge about SAS, I dont know how to achieve this in SAS. So I hope you could help me with this.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Last, after I create the new dataset, I want to know when each participant has the highest value of event during the day. Can I generate a new dataset looks like below:&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Screen Shot 2020-10-31 at 23.30.50.png" style="width: 133px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/51288iCF8BB7BC5C001591/image-size/large?v=v2&amp;amp;px=999" role="button" title="Screen Shot 2020-10-31 at 23.30.50.png" alt="Screen Shot 2020-10-31 at 23.30.50.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you very much！&lt;/P&gt;</description>
      <pubDate>Sun, 01 Nov 2020 03:34:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/sort-a-dataset/m-p/695713#M25194</guid>
      <dc:creator>knighsson</dc:creator>
      <dc:date>2020-11-01T03:34:15Z</dc:date>
    </item>
    <item>
      <title>Re: sort a dataset</title>
      <link>https://communities.sas.com/t5/New-SAS-User/sort-a-dataset/m-p/695720#M25196</link>
      <description>&lt;P&gt;First, transpose (PROC TRANSPOSE) to a long layout:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data long;
input participant $ eventno time :time8. value;
format time time8.;
datalines;
1 1 06:45:00 23
1 2 06:45:00 400
1 3 11:00:00 300
;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;(shortened example)&lt;/P&gt;
&lt;P&gt;It is then easy to group by time or participant.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please post example data as data steps with datalines (see above example), not as pictures. Pictures can't be used for development and testing.&lt;/P&gt;</description>
      <pubDate>Sun, 01 Nov 2020 06:23:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/sort-a-dataset/m-p/695720#M25196</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-11-01T06:23:58Z</dc:date>
    </item>
    <item>
      <title>Re: sort a dataset</title>
      <link>https://communities.sas.com/t5/New-SAS-User/sort-a-dataset/m-p/695746#M25197</link>
      <description>&lt;P&gt;Thank you! The example data is as follow.&lt;BR /&gt;Participant# Event # Time Value&lt;BR /&gt;1 1 06:45:00 23&lt;BR /&gt;1 2 06:45:00 400&lt;BR /&gt;1 3 11:00:00 300&lt;BR /&gt;1 4 11:00:00 100&lt;BR /&gt;1 5 18:00:00 500 &lt;BR /&gt;2 1 10:00:00 500&lt;BR /&gt;2 2 11:45:00 600&lt;BR /&gt;2 3 20:00:00 700&lt;/P&gt;</description>
      <pubDate>Sun, 01 Nov 2020 15:32:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/sort-a-dataset/m-p/695746#M25197</guid>
      <dc:creator>knighsson</dc:creator>
      <dc:date>2020-11-01T15:32:08Z</dc:date>
    </item>
    <item>
      <title>Re: sort a dataset</title>
      <link>https://communities.sas.com/t5/New-SAS-User/sort-a-dataset/m-p/695774#M25207</link>
      <description>&lt;P&gt;From this dataset, you can group by hour in this way:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
create table want as
  select
    intnx('hour',time,0,'b') as hour,
    sum(value) as value
  from have_long
  group by hour
;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 01 Nov 2020 20:40:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/sort-a-dataset/m-p/695774#M25207</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-11-01T20:40:32Z</dc:date>
    </item>
  </channel>
</rss>

