<?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 to create variable based on minutes in a certain level by ID in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-create-variable-based-on-minutes-in-a-certain-level-by-ID/m-p/795080#M254991</link>
    <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The times are all for one continuous period. The date does not really have an important place here. Essentially, I would need a code that looks through the stage column, and for example, if there were 10 7s listed for an ID, MINS_in_7 would 5 since it is binned in 30 sec increments.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The time variable shows 30 second increments.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you for your help!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 08 Feb 2022 23:09:55 GMT</pubDate>
    <dc:creator>marksanter</dc:creator>
    <dc:date>2022-02-08T23:09:55Z</dc:date>
    <item>
      <title>How to create variable based on minutes in a certain level by ID</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-create-variable-based-on-minutes-in-a-certain-level-by-ID/m-p/795056#M254979</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a dataset where I need to create minutes in separate levels by ID. The levels are 1-7 and time is structured in 30 second intervals. I essentially need new variables to capture the amount of time in mins spent in each level. I have attached example datasets of what I have and what I would like the data to look like.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can someone help me figure out a code to run this?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you for your help.&lt;/P&gt;</description>
      <pubDate>Tue, 08 Feb 2022 19:18:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-create-variable-based-on-minutes-in-a-certain-level-by-ID/m-p/795056#M254979</guid>
      <dc:creator>marksanter</dc:creator>
      <dc:date>2022-02-08T19:18:16Z</dc:date>
    </item>
    <item>
      <title>Re: How to create variable based on minutes in a certain level by ID</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-create-variable-based-on-minutes-in-a-certain-level-by-ID/m-p/795058#M254980</link>
      <description>&lt;P&gt;Many of us refuse to download Excel files because they are a security risk. The proper way to provide data is as SAS data step code (&lt;A href="https://blogs.sas.com/content/sastraining/2016/03/11/jedi-sas-tricks-data-to-data-step-macro/" target="_self"&gt;instructions&lt;/A&gt;).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;SPAN&gt;I essentially need new variables to capture the amount of time in mins spent in each level.&lt;/SPAN&gt;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&lt;SPAN&gt;Does this mean you want the SUM of minutes spent in each level?&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 08 Feb 2022 19:37:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-create-variable-based-on-minutes-in-a-certain-level-by-ID/m-p/795058#M254980</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2022-02-08T19:37:20Z</dc:date>
    </item>
    <item>
      <title>Re: How to create variable based on minutes in a certain level by ID</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-create-variable-based-on-minutes-in-a-certain-level-by-ID/m-p/795064#M254982</link>
      <description>&lt;P&gt;What are the rules to go from Have to Want?&amp;nbsp;&lt;BR /&gt;&lt;STRONG&gt;Can you take the first few rows and show the results?&lt;/STRONG&gt;&lt;BR /&gt;For example for duration you need a start and end time but you only have one time so how is the duration calculated?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I'm also assuming that all your times are for the same day, otherwise, if the date flips how do you know?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/281606"&gt;@marksanter&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have a dataset where I need to create minutes in separate levels by ID. The levels are 1-7 and time is structured in 30 second intervals. I essentially need new variables to capture the amount of time in mins spent in each level. I have attached example datasets of what I have and what I would like the data to look like.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Can someone help me figure out a code to run this?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you for your help.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 08 Feb 2022 20:08:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-create-variable-based-on-minutes-in-a-certain-level-by-ID/m-p/795064#M254982</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2022-02-08T20:08:18Z</dc:date>
    </item>
    <item>
      <title>Re: How to create variable based on minutes in a certain level by ID</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-create-variable-based-on-minutes-in-a-certain-level-by-ID/m-p/795077#M254989</link>
      <description>Yes, that is correct. And I apologize, I will provide the SAS data step code.</description>
      <pubDate>Tue, 08 Feb 2022 22:06:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-create-variable-based-on-minutes-in-a-certain-level-by-ID/m-p/795077#M254989</guid>
      <dc:creator>marksanter</dc:creator>
      <dc:date>2022-02-08T22:06:47Z</dc:date>
    </item>
    <item>
      <title>Re: How to create variable based on minutes in a certain level by ID</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-create-variable-based-on-minutes-in-a-certain-level-by-ID/m-p/795080#M254991</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The times are all for one continuous period. The date does not really have an important place here. Essentially, I would need a code that looks through the stage column, and for example, if there were 10 7s listed for an ID, MINS_in_7 would 5 since it is binned in 30 sec increments.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The time variable shows 30 second increments.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you for your help!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 08 Feb 2022 23:09:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-create-variable-based-on-minutes-in-a-certain-level-by-ID/m-p/795080#M254991</guid>
      <dc:creator>marksanter</dc:creator>
      <dc:date>2022-02-08T23:09:55Z</dc:date>
    </item>
    <item>
      <title>Re: How to create variable based on minutes in a certain level by ID</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-create-variable-based-on-minutes-in-a-certain-level-by-ID/m-p/795085#M254996</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc freq data=have noprint;
table id*level/&amp;nbsp;out=durations sparse missing;
run;

data&amp;nbsp;want;
set&amp;nbsp;durations;
time_in_period&amp;nbsp;=&amp;nbsp;count/2;
run;

*transpose&amp;nbsp;to&amp;nbsp;desired&amp;nbsp;structure;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;UL&gt;
&lt;LI&gt;Assume you mean by period instead of level (level has 8 categories 0-7, Period has 7, P1-P7). SInce you keep saying it has 7, I assume you're referring to Period not level.&amp;nbsp;&lt;/LI&gt;
&lt;LI&gt;See if the above gives you the answers you want. If so let us know and we can show you how to transpose and remerge it back into the main data set if you really want the structure you've shown.&amp;nbsp;&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 08 Feb 2022 23:42:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-create-variable-based-on-minutes-in-a-certain-level-by-ID/m-p/795085#M254996</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2022-02-08T23:42:16Z</dc:date>
    </item>
  </channel>
</rss>

