<?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: Create time interval as a categorical variable in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Create-time-interval-as-a-categorical-variable/m-p/523788#M4686</link>
    <description>&lt;P&gt;Are you looking to do this?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if '10:30't&amp;lt;=Timeconsumed&amp;lt;'11:30't then LunchPeriod1= 1;
else LunchPeriod1= 0;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If yes, you could use that syntax for all the others&lt;/P&gt;</description>
    <pubDate>Fri, 28 Dec 2018 18:32:59 GMT</pubDate>
    <dc:creator>novinosrin</dc:creator>
    <dc:date>2018-12-28T18:32:59Z</dc:date>
    <item>
      <title>Create time interval as a categorical variable</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Create-time-interval-as-a-categorical-variable/m-p/523784#M4685</link>
      <description>&lt;P&gt;Hi, I need assistance with creating&amp;nbsp; categorical time group (intervals) variables to be used in logistic regression.&lt;/P&gt;&lt;P&gt;Similar to the way you would create an AGEGROUP variable. I'm currently using SAS Studio.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is my code so far:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Data BK4;&lt;BR /&gt;set BK3;&lt;BR /&gt;FORMAT Timeconsumed time6.;&lt;BR /&gt;if Timeconsumed&amp;nbsp; ge 10:30 and ln 11:30 then LunchPeriod1= 1;&lt;BR /&gt;else LunchPeriod1= 0;&lt;BR /&gt;if Timeconsumed&amp;nbsp; ge 11:30 and ln 12:30 then LunchPeriod2= 1;&lt;BR /&gt;else&amp;nbsp; LunchPeriod2= 0;&lt;BR /&gt;if Timeconsumed&amp;nbsp; ge 12:30 and ln 13:30 then LunchPeriod3= 1;&lt;BR /&gt;else&amp;nbsp; LunchPeriod3= 0;&lt;BR /&gt;if Timeconsumed&amp;nbsp; ge 13:30 and ln 14:30 then LunchPeriod4= 1;&lt;BR /&gt;else&amp;nbsp; LunchPeriod4= 0;&lt;BR /&gt;if Timeconsumed&amp;nbsp; ge 14:30 then LunchPeriod5= 1;&lt;BR /&gt;else LunchPeriod5= 0;&lt;BR /&gt;else= .;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I keep getting these error messages:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;ERROR 22-322: Syntax error, expecting one of the following: &amp;lt;, &amp;lt;=, =, &amp;gt;, &amp;gt;=, EQ, GE, GT, LE, LT, NE, NG, NL, ^=, ~=.&amp;nbsp;&lt;/P&gt;&lt;DIV class="sasSource"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class="sasError"&gt;ERROR 76-322: Syntax error, statement will be ignored.&lt;/DIV&gt;&lt;DIV class="sasError"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class="sasError"&gt;Any help would be much appreciated!&lt;/DIV&gt;</description>
      <pubDate>Fri, 28 Dec 2018 18:16:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Create-time-interval-as-a-categorical-variable/m-p/523784#M4685</guid>
      <dc:creator>BernieK</dc:creator>
      <dc:date>2018-12-28T18:16:03Z</dc:date>
    </item>
    <item>
      <title>Re: Create time interval as a categorical variable</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Create-time-interval-as-a-categorical-variable/m-p/523788#M4686</link>
      <description>&lt;P&gt;Are you looking to do this?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if '10:30't&amp;lt;=Timeconsumed&amp;lt;'11:30't then LunchPeriod1= 1;
else LunchPeriod1= 0;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If yes, you could use that syntax for all the others&lt;/P&gt;</description>
      <pubDate>Fri, 28 Dec 2018 18:32:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Create-time-interval-as-a-categorical-variable/m-p/523788#M4686</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2018-12-28T18:32:59Z</dc:date>
    </item>
    <item>
      <title>Re: Create time interval as a categorical variable</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Create-time-interval-as-a-categorical-variable/m-p/523790#M4687</link>
      <description>&lt;P&gt;First, not completely sure on this but I don't think SAS reads &lt;STRONG&gt;10:30&lt;/STRONG&gt; literally as time.&amp;nbsp; Most likely you need to to use something like &lt;STRONG&gt;'10:30't&lt;/STRONG&gt; formulation.&amp;nbsp; You can look up how to reference time yourself.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Second, your AND is followed by LN which is a natural log.&amp;nbsp; I believe you need to use LE for 'less than or equal to'.&amp;nbsp; You also need to repeat the variable name after the AND like this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data BK4;
  set BK3;
  if TimeConsumed GE '10:30't AND TimeConsumed LE '11:30't
    then LunchPeriod1= 1;
    else LunchPeriod1= 0;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The code is not tested.&amp;nbsp; You'll need to look up how to reference a variable with time format.&lt;/P&gt;</description>
      <pubDate>Fri, 28 Dec 2018 18:41:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Create-time-interval-as-a-categorical-variable/m-p/523790#M4687</guid>
      <dc:creator>Haris</dc:creator>
      <dc:date>2018-12-28T18:41:03Z</dc:date>
    </item>
  </channel>
</rss>

