<?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: Time variable into categorical in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Time-variable-into-categorical/m-p/749258#M235405</link>
    <description>&lt;P&gt;Thank you very much Kurt. It seems to work perfectly well for subjects who have a time in the &lt;EM&gt;timestop&lt;/EM&gt; variable.&lt;/P&gt;&lt;P&gt;The only problem is that I have a 1 in the &lt;EM&gt;timestopnight&lt;/EM&gt; column in patients who don't have value for the&amp;nbsp;&lt;EM&gt;timestop &lt;/EM&gt;variable.&lt;/P&gt;&lt;P&gt;I've tried to insert&amp;nbsp;&amp;nbsp;before but it didn't work.&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;timestopnight = .;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Could you help me with that ?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have attached the log but the variable names are different since I've tried to simplify for the post.&lt;/P&gt;&lt;P&gt;Thanks again for your help+++&lt;/P&gt;&lt;P&gt;Rodrigue&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Rodrigue_0-1624282770076.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/60554i01C9A85D22180AAA/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Rodrigue_0-1624282770076.png" alt="Rodrigue_0-1624282770076.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 21 Jun 2021 13:43:51 GMT</pubDate>
    <dc:creator>Rodrigue</dc:creator>
    <dc:date>2021-06-21T13:43:51Z</dc:date>
    <item>
      <title>Time variable into categorical</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Time-variable-into-categorical/m-p/749245#M235398</link>
      <description>&lt;P&gt;Hi ! Please I need you help+++&lt;/P&gt;&lt;P&gt;I have a time variable HH:MM called "timestop" and I would like to create a new categorical variable "timestopnight" stating 1 if the timestop was between 23:00 and 7:00 and 0 if the timestop was between 07:00 and 23:00.&lt;/P&gt;&lt;P&gt;I have tried several codes like the following but none worked.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data dataset ; set dataset;&lt;/P&gt;&lt;P&gt;if timestop &amp;lt; '07:00't then timestopnight=1;&lt;/P&gt;&lt;P&gt;if timestop &amp;gt; '23:00't then timestopnight=1;&lt;/P&gt;&lt;P&gt;if&amp;nbsp; '07:00't =&amp;lt;timestop =&amp;lt; '23:00't then timestopnight=0;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks a lot for your help&amp;nbsp;&lt;span class="lia-unicode-emoji" title=":folded_hands:"&gt;🙏&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Rodrigue&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 21 Jun 2021 12:35:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Time-variable-into-categorical/m-p/749245#M235398</guid>
      <dc:creator>Rodrigue</dc:creator>
      <dc:date>2021-06-21T12:35:28Z</dc:date>
    </item>
    <item>
      <title>Re: Time variable into categorical</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Time-variable-into-categorical/m-p/749247#M235400</link>
      <description>&lt;P&gt;I think you need to use if else if.&lt;/P&gt;</description>
      <pubDate>Mon, 21 Jun 2021 12:38:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Time-variable-into-categorical/m-p/749247#M235400</guid>
      <dc:creator>tarheel13</dc:creator>
      <dc:date>2021-06-21T12:38:35Z</dc:date>
    </item>
    <item>
      <title>Re: Time variable into categorical</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Time-variable-into-categorical/m-p/749248#M235401</link>
      <description>&lt;P&gt;Can also do a boolean.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;timestopnight=&lt;SPAN&gt;07:00't le timestop le 23:00't;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;This will assign 1 if the condition is true and 0 if it's&amp;nbsp;false.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 21 Jun 2021 12:40:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Time-variable-into-categorical/m-p/749248#M235401</guid>
      <dc:creator>tarheel13</dc:creator>
      <dc:date>2021-06-21T12:40:09Z</dc:date>
    </item>
    <item>
      <title>Re: Time variable into categorical</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Time-variable-into-categorical/m-p/749255#M235404</link>
      <description>&lt;P&gt;Please post the complete log from that step.&lt;/P&gt;
&lt;P&gt;If timestop is a SAS time, this will work:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;timestopnight = ifn('07:00't le timestop le '23:00't,0,1);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Be observant if timestop is a datetime instead of just time.&lt;/P&gt;</description>
      <pubDate>Mon, 21 Jun 2021 13:19:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Time-variable-into-categorical/m-p/749255#M235404</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2021-06-21T13:19:05Z</dc:date>
    </item>
    <item>
      <title>Re: Time variable into categorical</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Time-variable-into-categorical/m-p/749258#M235405</link>
      <description>&lt;P&gt;Thank you very much Kurt. It seems to work perfectly well for subjects who have a time in the &lt;EM&gt;timestop&lt;/EM&gt; variable.&lt;/P&gt;&lt;P&gt;The only problem is that I have a 1 in the &lt;EM&gt;timestopnight&lt;/EM&gt; column in patients who don't have value for the&amp;nbsp;&lt;EM&gt;timestop &lt;/EM&gt;variable.&lt;/P&gt;&lt;P&gt;I've tried to insert&amp;nbsp;&amp;nbsp;before but it didn't work.&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;timestopnight = .;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Could you help me with that ?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have attached the log but the variable names are different since I've tried to simplify for the post.&lt;/P&gt;&lt;P&gt;Thanks again for your help+++&lt;/P&gt;&lt;P&gt;Rodrigue&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Rodrigue_0-1624282770076.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/60554i01C9A85D22180AAA/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Rodrigue_0-1624282770076.png" alt="Rodrigue_0-1624282770076.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 21 Jun 2021 13:43:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Time-variable-into-categorical/m-p/749258#M235405</guid>
      <dc:creator>Rodrigue</dc:creator>
      <dc:date>2021-06-21T13:43:51Z</dc:date>
    </item>
    <item>
      <title>Re: Time variable into categorical</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Time-variable-into-categorical/m-p/749281#M235419</link>
      <description>&lt;P&gt;I found the solution adding&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if not missing (timestop) &lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 21 Jun 2021 15:29:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Time-variable-into-categorical/m-p/749281#M235419</guid>
      <dc:creator>Rodrigue</dc:creator>
      <dc:date>2021-06-21T15:29:35Z</dc:date>
    </item>
    <item>
      <title>Re: Time variable into categorical</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Time-variable-into-categorical/m-p/749295#M235428</link>
      <description>&lt;P&gt;MISSING values are always less than any actual value.&lt;/P&gt;
&lt;P&gt;Always.&lt;/P&gt;</description>
      <pubDate>Mon, 21 Jun 2021 15:54:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Time-variable-into-categorical/m-p/749295#M235428</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2021-06-21T15:54:26Z</dc:date>
    </item>
  </channel>
</rss>

