<?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 Working with military time in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Working-with-military-time/m-p/398906#M278443</link>
    <description>&lt;P&gt;Having issues subtracting military time from two variables&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;variable one is the time people woke up (wokeup)&lt;/P&gt;&lt;P&gt;&amp;nbsp;variable two is the time people went to sleep (sleep)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to find the amount of hours they subjects sleep.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I created a third variable hours where i substracted noth variables&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;and the results are not giving the hours.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;can you please point me to the right direction...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;this the data&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;IF H4SP1H = 1 AND H4SP1T =1 THEN WHOUR24 = 0100;&lt;BR /&gt;IF H4SP1H = 2 AND H4SP1T =1 THEN WHOUR24 = 0200;&lt;BR /&gt;IF H4SP1H = 3 AND H4SP1T =1 THEN WHOUR24 = 0300;&lt;BR /&gt;IF H4SP1H = 4 AND H4SP1T =1 THEN WHOUR24 = 0400;&lt;BR /&gt;IF H4SP1H = 5 AND H4SP1T =1 THEN WHOUR24 = 0500;&lt;BR /&gt;IF H4SP1H = 6 AND H4SP1T =1 THEN WHOUR24 = 0600;&lt;BR /&gt;IF H4SP1H = 7 AND H4SP1T =1 THEN WHOUR24 = 0700;&lt;BR /&gt;IF H4SP1H = 8 AND H4SP1T =1 THEN WHOUR24 = 0800;&lt;BR /&gt;IF H4SP1H = 9 AND H4SP1T =1 THEN WHOUR24 = 0900;&lt;BR /&gt;IF H4SP1H = 10 AND H4SP1T =1 THEN WHOUR24 = 1000;&lt;BR /&gt;IF H4SP1H = 11 AND H4SP1T =1 THEN WHOUR24 = 1100;&lt;BR /&gt;IF H4SP1H = 12 AND H4SP1T =1 THEN WHOUR24 = 0000;&lt;BR /&gt;IF H4SP1H = 1 AND H4SP1T =2 THEN WHOUR24 = 1300;&lt;BR /&gt;IF H4SP1H = 2 AND H4SP1T =2 THEN WHOUR24 = 1400;&lt;BR /&gt;IF H4SP1H = 3 AND H4SP1T =2 THEN wHOUR24 = 1500;&lt;BR /&gt;IF H4SP1H = 4 AND H4SP1T =2 THEN WHOUR24 = 1600;&lt;BR /&gt;IF H4SP1H = 5 AND H4SP1T =2 THEN WHOUR24 = 1700;&lt;BR /&gt;IF H4SP1H = 6 AND H4SP1T =2 THEN WHOUR24 = 1800;&lt;BR /&gt;IF H4SP1H = 7 AND H4SP1T =2 THEN WHOUR24 = 1900;&lt;BR /&gt;IF H4SP1H = 8 AND H4SP1T =2 THEN WHOUR24 = 2000;&lt;BR /&gt;IF H4SP1H = 9 AND H4SP1T =2 THEN WHOUR24 = 2100;&lt;BR /&gt;IF H4SP1H = 10 AND H4SP1T =2 THEN WHOUR24 = 2200;&lt;BR /&gt;IF H4SP1H = 11 AND H4SP1T =2 THEN wHOUR24 = 2300;&lt;BR /&gt;IF H4SP1H = 12 AND H4SP1T =2 THEN wHOUR24 = 1200;&lt;BR /&gt;WoScWake=SUM(of H4SP1M WHOUR24); /*work or school next day*/&lt;/PRE&gt;&lt;PRE&gt;IF H4SP2H = 1 AND H4SP2T =1 THEN HOUR24 = 0100;&lt;BR /&gt;IF H4SP2H = 2 AND H4SP2T =1 THEN HOUR24 = 0200;&lt;BR /&gt;IF H4SP2H = 3 AND H4SP2T =1 THEN HOUR24 = 0300;&lt;BR /&gt;IF H4SP2H = 4 AND H4SP2T =1 THEN HOUR24 = 0400;&lt;BR /&gt;IF H4SP2H = 5 AND H4SP2T =1 THEN HOUR24 = 0500;&lt;BR /&gt;IF H4SP2H = 6 AND H4SP2T =1 THEN HOUR24 = 0600;&lt;BR /&gt;IF H4SP2H = 7 AND H4SP2T =1 THEN HOUR24 = 0700;&lt;BR /&gt;IF H4SP2H = 8 AND H4SP2T =1 THEN HOUR24 = 0800;&lt;BR /&gt;IF H4SP2H = 9 AND H4SP2T =1 THEN HOUR24 = 0900;&lt;BR /&gt;IF H4SP2H = 10 AND H4SP2T =1 THEN HOUR24 = 1000;&lt;BR /&gt;IF H4SP2H = 11 AND H4SP2T =1 THEN HOUR24 = 1100;&lt;BR /&gt;IF H4SP2H = 12 AND H4SP2T =1 THEN HOUR24 = 0000;&lt;BR /&gt;IF H4SP2H = 1 AND H4SP2T =2 THEN HOUR24 = 1300;&lt;BR /&gt;IF H4SP2H = 2 AND H4SP2T =2 THEN HOUR24 = 1400;&lt;BR /&gt;IF H4SP2H = 3 AND H4SP2T =2 THEN HOUR24 = 1500;&lt;BR /&gt;IF H4SP2H = 4 AND H4SP2T =2 THEN HOUR24 = 1600;&lt;BR /&gt;IF H4SP2H = 5 AND H4SP2T =2 THEN HOUR24 = 1700;&lt;BR /&gt;IF H4SP2H = 6 AND H4SP2T =2 THEN HOUR24 = 1800;&lt;BR /&gt;IF H4SP2H = 7 AND H4SP2T =2 THEN HOUR24 = 1900;&lt;BR /&gt;IF H4SP2H = 8 AND H4SP2T =2 THEN HOUR24 = 2000;&lt;BR /&gt;IF H4SP2H = 9 AND H4SP2T =2 THEN HOUR24 = 2100;&lt;BR /&gt;IF H4SP2H = 10 AND H4SP2T =2 THEN HOUR24 = 2200;&lt;BR /&gt;IF H4SP2H = 11 AND H4SP2T =2 THEN HOUR24 = 2300;&lt;BR /&gt;IF H4SP2H = 12 AND H4SP2T =2 THEN HOUR24 = 1200;&lt;BR /&gt;WoScSleep=SUM(of H4SP2M HOUR24); /*no work or school next day*/&lt;/PRE&gt;&lt;PRE&gt;getuphs=WoScWake-WoScSleep;&lt;/PRE&gt;</description>
    <pubDate>Tue, 26 Sep 2017 19:03:32 GMT</pubDate>
    <dc:creator>Lavdiff</dc:creator>
    <dc:date>2017-09-26T19:03:32Z</dc:date>
    <item>
      <title>Working with military time</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Working-with-military-time/m-p/398906#M278443</link>
      <description>&lt;P&gt;Having issues subtracting military time from two variables&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;variable one is the time people woke up (wokeup)&lt;/P&gt;&lt;P&gt;&amp;nbsp;variable two is the time people went to sleep (sleep)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to find the amount of hours they subjects sleep.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I created a third variable hours where i substracted noth variables&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;and the results are not giving the hours.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;can you please point me to the right direction...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;this the data&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;IF H4SP1H = 1 AND H4SP1T =1 THEN WHOUR24 = 0100;&lt;BR /&gt;IF H4SP1H = 2 AND H4SP1T =1 THEN WHOUR24 = 0200;&lt;BR /&gt;IF H4SP1H = 3 AND H4SP1T =1 THEN WHOUR24 = 0300;&lt;BR /&gt;IF H4SP1H = 4 AND H4SP1T =1 THEN WHOUR24 = 0400;&lt;BR /&gt;IF H4SP1H = 5 AND H4SP1T =1 THEN WHOUR24 = 0500;&lt;BR /&gt;IF H4SP1H = 6 AND H4SP1T =1 THEN WHOUR24 = 0600;&lt;BR /&gt;IF H4SP1H = 7 AND H4SP1T =1 THEN WHOUR24 = 0700;&lt;BR /&gt;IF H4SP1H = 8 AND H4SP1T =1 THEN WHOUR24 = 0800;&lt;BR /&gt;IF H4SP1H = 9 AND H4SP1T =1 THEN WHOUR24 = 0900;&lt;BR /&gt;IF H4SP1H = 10 AND H4SP1T =1 THEN WHOUR24 = 1000;&lt;BR /&gt;IF H4SP1H = 11 AND H4SP1T =1 THEN WHOUR24 = 1100;&lt;BR /&gt;IF H4SP1H = 12 AND H4SP1T =1 THEN WHOUR24 = 0000;&lt;BR /&gt;IF H4SP1H = 1 AND H4SP1T =2 THEN WHOUR24 = 1300;&lt;BR /&gt;IF H4SP1H = 2 AND H4SP1T =2 THEN WHOUR24 = 1400;&lt;BR /&gt;IF H4SP1H = 3 AND H4SP1T =2 THEN wHOUR24 = 1500;&lt;BR /&gt;IF H4SP1H = 4 AND H4SP1T =2 THEN WHOUR24 = 1600;&lt;BR /&gt;IF H4SP1H = 5 AND H4SP1T =2 THEN WHOUR24 = 1700;&lt;BR /&gt;IF H4SP1H = 6 AND H4SP1T =2 THEN WHOUR24 = 1800;&lt;BR /&gt;IF H4SP1H = 7 AND H4SP1T =2 THEN WHOUR24 = 1900;&lt;BR /&gt;IF H4SP1H = 8 AND H4SP1T =2 THEN WHOUR24 = 2000;&lt;BR /&gt;IF H4SP1H = 9 AND H4SP1T =2 THEN WHOUR24 = 2100;&lt;BR /&gt;IF H4SP1H = 10 AND H4SP1T =2 THEN WHOUR24 = 2200;&lt;BR /&gt;IF H4SP1H = 11 AND H4SP1T =2 THEN wHOUR24 = 2300;&lt;BR /&gt;IF H4SP1H = 12 AND H4SP1T =2 THEN wHOUR24 = 1200;&lt;BR /&gt;WoScWake=SUM(of H4SP1M WHOUR24); /*work or school next day*/&lt;/PRE&gt;&lt;PRE&gt;IF H4SP2H = 1 AND H4SP2T =1 THEN HOUR24 = 0100;&lt;BR /&gt;IF H4SP2H = 2 AND H4SP2T =1 THEN HOUR24 = 0200;&lt;BR /&gt;IF H4SP2H = 3 AND H4SP2T =1 THEN HOUR24 = 0300;&lt;BR /&gt;IF H4SP2H = 4 AND H4SP2T =1 THEN HOUR24 = 0400;&lt;BR /&gt;IF H4SP2H = 5 AND H4SP2T =1 THEN HOUR24 = 0500;&lt;BR /&gt;IF H4SP2H = 6 AND H4SP2T =1 THEN HOUR24 = 0600;&lt;BR /&gt;IF H4SP2H = 7 AND H4SP2T =1 THEN HOUR24 = 0700;&lt;BR /&gt;IF H4SP2H = 8 AND H4SP2T =1 THEN HOUR24 = 0800;&lt;BR /&gt;IF H4SP2H = 9 AND H4SP2T =1 THEN HOUR24 = 0900;&lt;BR /&gt;IF H4SP2H = 10 AND H4SP2T =1 THEN HOUR24 = 1000;&lt;BR /&gt;IF H4SP2H = 11 AND H4SP2T =1 THEN HOUR24 = 1100;&lt;BR /&gt;IF H4SP2H = 12 AND H4SP2T =1 THEN HOUR24 = 0000;&lt;BR /&gt;IF H4SP2H = 1 AND H4SP2T =2 THEN HOUR24 = 1300;&lt;BR /&gt;IF H4SP2H = 2 AND H4SP2T =2 THEN HOUR24 = 1400;&lt;BR /&gt;IF H4SP2H = 3 AND H4SP2T =2 THEN HOUR24 = 1500;&lt;BR /&gt;IF H4SP2H = 4 AND H4SP2T =2 THEN HOUR24 = 1600;&lt;BR /&gt;IF H4SP2H = 5 AND H4SP2T =2 THEN HOUR24 = 1700;&lt;BR /&gt;IF H4SP2H = 6 AND H4SP2T =2 THEN HOUR24 = 1800;&lt;BR /&gt;IF H4SP2H = 7 AND H4SP2T =2 THEN HOUR24 = 1900;&lt;BR /&gt;IF H4SP2H = 8 AND H4SP2T =2 THEN HOUR24 = 2000;&lt;BR /&gt;IF H4SP2H = 9 AND H4SP2T =2 THEN HOUR24 = 2100;&lt;BR /&gt;IF H4SP2H = 10 AND H4SP2T =2 THEN HOUR24 = 2200;&lt;BR /&gt;IF H4SP2H = 11 AND H4SP2T =2 THEN HOUR24 = 2300;&lt;BR /&gt;IF H4SP2H = 12 AND H4SP2T =2 THEN HOUR24 = 1200;&lt;BR /&gt;WoScSleep=SUM(of H4SP2M HOUR24); /*no work or school next day*/&lt;/PRE&gt;&lt;PRE&gt;getuphs=WoScWake-WoScSleep;&lt;/PRE&gt;</description>
      <pubDate>Tue, 26 Sep 2017 19:03:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Working-with-military-time/m-p/398906#M278443</guid>
      <dc:creator>Lavdiff</dc:creator>
      <dc:date>2017-09-26T19:03:32Z</dc:date>
    </item>
    <item>
      <title>Re: Working with military time</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Working-with-military-time/m-p/398912#M278444</link>
      <description>&lt;P&gt;Either post a data step that creates your dataset, or post sample lines from the external file that contains your timestamps in a {i} window.&lt;/P&gt;
&lt;P&gt;MS Office files are blocked against download at many corporate sites, for security reasons.&lt;/P&gt;</description>
      <pubDate>Tue, 26 Sep 2017 18:58:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Working-with-military-time/m-p/398912#M278444</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2017-09-26T18:58:45Z</dc:date>
    </item>
    <item>
      <title>Re: Working with military time</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Working-with-military-time/m-p/398913#M278445</link>
      <description>thank you will do</description>
      <pubDate>Tue, 26 Sep 2017 19:01:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Working-with-military-time/m-p/398913#M278445</guid>
      <dc:creator>Lavdiff</dc:creator>
      <dc:date>2017-09-26T19:01:02Z</dc:date>
    </item>
    <item>
      <title>Re: Working with military time</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Working-with-military-time/m-p/398925#M278446</link>
      <description>&lt;P&gt;First of all, you should start by using SAS datetime values. As these are a count of seconds from a given starting point, they can easily be used in a subtraction, and the result just needs a time format to display in a human-readable form.&lt;/P&gt;
&lt;P&gt;So you need to create timestamps from your military times; to assist you, we would need the original timestamps that contain your sleep/wake times.&lt;/P&gt;</description>
      <pubDate>Tue, 26 Sep 2017 19:26:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Working-with-military-time/m-p/398925#M278446</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2017-09-26T19:26:34Z</dc:date>
    </item>
    <item>
      <title>Re: Working with military time</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Working-with-military-time/m-p/398958#M278447</link>
      <description>&lt;P&gt;You can reduce all your IF statements to a couple of assignments statement using the HMS (hours/minutes/seconds) function to create sas times values, which are the number of seconds after midnight.&amp;nbsp; These values can be added/substract to get the number of seconds between time points, i.e. itervals in seconds.&amp;nbsp; Then you can format the resulting value to print out in military time form (basically HHMM without the colon).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc format ;
  picture miltime
    low-high = '%0H%0M'  (datatype=time) ;
run;

data want;
  set have;
  time1=hms(mod(h4sp1h,12),h4sp1m,0);
  if h4sp1t=2 then time1=time1+'12:00:00't;

  time2=hms(mod(h4sp2h,12),h4sp2m,0);
  if h4sp2t=2 then time2=time2+'12:00:00't;

  getup_time=time1-time2;

  format time1 time2 getup_time miltime4.;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This format works fine on TIME1 and TIME2.&amp;nbsp; And it works on GETUP_TIME if it is non-negative.&lt;/P&gt;</description>
      <pubDate>Tue, 26 Sep 2017 21:47:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Working-with-military-time/m-p/398958#M278447</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2017-09-26T21:47:46Z</dc:date>
    </item>
    <item>
      <title>Re: Working with military time</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Working-with-military-time/m-p/399212#M278448</link>
      <description>can you provide me with an example? thank you</description>
      <pubDate>Wed, 27 Sep 2017 14:57:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Working-with-military-time/m-p/399212#M278448</guid>
      <dc:creator>Lavdiff</dc:creator>
      <dc:date>2017-09-27T14:57:34Z</dc:date>
    </item>
    <item>
      <title>Re: Working with military time</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Working-with-military-time/m-p/399224#M278449</link>
      <description>THANK YOU!!!</description>
      <pubDate>Wed, 27 Sep 2017 15:21:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Working-with-military-time/m-p/399224#M278449</guid>
      <dc:creator>Lavdiff</dc:creator>
      <dc:date>2017-09-27T15:21:54Z</dc:date>
    </item>
  </channel>
</rss>

