<?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 SAS Time Variable Question in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/SAS-Time-Variable-Question/m-p/128229#M26202</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I have a (perhaps) rather simple question. I am working on real time data that looks like this:&lt;/P&gt;&lt;TABLE border="1" class="jiveBorder" style="border: 1px solid rgb(0, 0, 0); width: 100%;"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TH style="text-align: center; background-color: #6690bc; color: #ffffff; padding: 2px;" valign="middle"&gt;Sample Location&lt;/TH&gt;&lt;TH style="text-align: center; background-color: #6690bc; color: #ffffff; padding: 2px;" valign="middle"&gt;Date&lt;/TH&gt;&lt;TH style="text-align: center; background-color: #6690bc; color: #ffffff; padding: 2px;" valign="middle"&gt;Time&lt;/TH&gt;&lt;TH style="text-align: center; background-color: #6690bc; color: #ffffff; padding: 2px;" valign="middle"&gt;Concentration X&lt;/TH&gt;&lt;TH style="text-align: center; background-color: #6690bc; color: #ffffff; padding: 2px;" valign="middle"&gt;Concentration Y&lt;/TH&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;Office&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;08/09/2009&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;1:00:00&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;2&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;7&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;Office&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;08/09/2009&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;1:00:10&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;5&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;5&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;Office&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;08/09/2009&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;1:00:30&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;5&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;6&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;There are several sampling locations, dates, and times. I would like to obtain average concentrations in these different areas, different dates (day of the week), and different times (morning, noon, evening, overnight).&lt;/P&gt;&lt;P&gt; I understand how to do this for sample location using proc means, but I get stumped when I need to do this for time and date variables.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I originally used proc means for different times of day but SAS did not understand this:&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;BR /&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;My questions are as follows:&lt;/P&gt;&lt;P&gt;1. Do I need to transform my 'Time' variable, because SAS does not seem to recognize this as time? If so, how do I do this. I was thinking of making a dummy variable for morning, noon, evening, overnight but SAS does not seem to recognize the time as it is in my database. &lt;/P&gt;&lt;P&gt;2. The same question but for Date. Are there any transformations that need to be made?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank-You. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 22 Sep 2012 14:51:20 GMT</pubDate>
    <dc:creator>dubya</dc:creator>
    <dc:date>2012-09-22T14:51:20Z</dc:date>
    <item>
      <title>SAS Time Variable Question</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-Time-Variable-Question/m-p/128229#M26202</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I have a (perhaps) rather simple question. I am working on real time data that looks like this:&lt;/P&gt;&lt;TABLE border="1" class="jiveBorder" style="border: 1px solid rgb(0, 0, 0); width: 100%;"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TH style="text-align: center; background-color: #6690bc; color: #ffffff; padding: 2px;" valign="middle"&gt;Sample Location&lt;/TH&gt;&lt;TH style="text-align: center; background-color: #6690bc; color: #ffffff; padding: 2px;" valign="middle"&gt;Date&lt;/TH&gt;&lt;TH style="text-align: center; background-color: #6690bc; color: #ffffff; padding: 2px;" valign="middle"&gt;Time&lt;/TH&gt;&lt;TH style="text-align: center; background-color: #6690bc; color: #ffffff; padding: 2px;" valign="middle"&gt;Concentration X&lt;/TH&gt;&lt;TH style="text-align: center; background-color: #6690bc; color: #ffffff; padding: 2px;" valign="middle"&gt;Concentration Y&lt;/TH&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;Office&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;08/09/2009&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;1:00:00&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;2&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;7&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;Office&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;08/09/2009&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;1:00:10&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;5&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;5&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;Office&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;08/09/2009&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;1:00:30&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;5&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;6&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;There are several sampling locations, dates, and times. I would like to obtain average concentrations in these different areas, different dates (day of the week), and different times (morning, noon, evening, overnight).&lt;/P&gt;&lt;P&gt; I understand how to do this for sample location using proc means, but I get stumped when I need to do this for time and date variables.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I originally used proc means for different times of day but SAS did not understand this:&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;BR /&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;My questions are as follows:&lt;/P&gt;&lt;P&gt;1. Do I need to transform my 'Time' variable, because SAS does not seem to recognize this as time? If so, how do I do this. I was thinking of making a dummy variable for morning, noon, evening, overnight but SAS does not seem to recognize the time as it is in my database. &lt;/P&gt;&lt;P&gt;2. The same question but for Date. Are there any transformations that need to be made?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank-You. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 22 Sep 2012 14:51:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-Time-Variable-Question/m-p/128229#M26202</guid>
      <dc:creator>dubya</dc:creator>
      <dc:date>2012-09-22T14:51:20Z</dc:date>
    </item>
    <item>
      <title>Re: SAS Time Variable Question</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-Time-Variable-Question/m-p/128230#M26203</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Your values look like times.&amp;nbsp; In SAS a time value is a numeric variable with the number of seconds since midnight.&lt;/P&gt;&lt;P&gt;To create your dummy variables should be simple.&amp;nbsp; You can use the WEEKDAY() function to convert a date to a day of the week (1=Sunday).&lt;/P&gt;&lt;P&gt;You can divide the day into what ever parts you want. In the example below I divide it into 6 hour windows.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;data sample;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; input location $ date :mmddyy10. time :time8. x y;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; format date yymmdd10. time time8.;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; dow=weekday(date);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; tod=1+int(time/'06:00't);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;cards;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;Office 08/09/2009 1:00:00 2 7&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;Office 08/09/2009 9:00:10 5 5&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;Office 08/10/2009 13:00:30 5 6&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;run;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 22 Sep 2012 15:51:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-Time-Variable-Question/m-p/128230#M26203</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2012-09-22T15:51:11Z</dc:date>
    </item>
    <item>
      <title>Re: SAS Time Variable Question</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-Time-Variable-Question/m-p/128231#M26204</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you, Tom!&lt;/P&gt;&lt;P&gt;So, if you don't mind, can I break this code into digestible chunks?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;data sample; &lt;STRONG&gt;(I understand this)&lt;/STRONG&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; input location $ date :mmddyy10. time :time8. x y; &lt;STRONG&gt;(Are the next two lines of command formatting data into what SAS can read?)&lt;/STRONG&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; format date yymmdd10. time time8.;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; dow=weekday(date); &lt;STRONG&gt;(This give us a variable that codes our days of the week?)&lt;/STRONG&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; tod=1+int(time/'06:00't); &lt;STRONG&gt;(This is our time of day variable, which tells us that we are going to break the day into 6 hour time intervals?)&lt;/STRONG&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;cards; &lt;STRONG&gt;(I understand this)&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: 'courier new',courier;"&gt;The commands here I'm not following: &lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;SPAN style="font-family: 'courier new',courier;"&gt;I don't understand what the below three lines are doing. &lt;/SPAN&gt;&lt;SPAN style="font-family: 'courier new',courier;"&gt;It looks like it is defining when these 6 hours start and end? &lt;BR /&gt;&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;Office 08/09/2009 1:00:00 2 7 &lt;STRONG&gt;(I'm also not sure what the numbers on the end mean--2, 7, or 5,5)&lt;/STRONG&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;Office 08/09/2009 9:00:10 5 5&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;Office 08/10/2009 13:00:30 5 6 &lt;STRONG&gt;(Not sure why this switched to the 10th)&lt;/STRONG&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;run;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;So, my times of day are as follows:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;SPAN style="font-size: 11.0pt; font-family: 'Calibri','sans-serif';"&gt;morning (6am-12pm) &lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 11.0pt; font-family: 'Calibri','sans-serif';"&gt; afternoon (12pm-6pm)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 11.0pt; font-family: 'Calibri','sans-serif';"&gt; evening (6pm-12am),&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 11.0pt; font-family: 'Calibri','sans-serif';"&gt;overnight/night (12am-6am)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 11.0pt; font-family: 'Calibri','sans-serif';"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 11.0pt; font-family: 'Calibri','sans-serif';"&gt;and sampling locations are office, dock, yard&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 11.0pt; font-family: 'Calibri','sans-serif';"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 11.0pt; font-family: 'Calibri','sans-serif';"&gt;So, would code be something like?&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;Office 08/09/2009 1:00:00 2 7 &lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;Office 08/09/2009 9:00:10 5 5&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;Office 08/10/2009 13:00:30 5 6&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;.Office 08/16/2009&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;Dock 08/09/2009 1:00:00 2 7 &lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;Dock 08/09/2009 9:00:10 5 5&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;Dock 08/10/2009 13:00:30 5 6&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;Dock 08/16/2009&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;.&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;run;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;Sorry for so many questions. I'm new not very proficient in SAS. Thank you so much for your response.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 22 Sep 2012 16:35:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-Time-Variable-Question/m-p/128231#M26204</guid>
      <dc:creator>dubya</dc:creator>
      <dc:date>2012-09-22T16:35:54Z</dc:date>
    </item>
    <item>
      <title>Re: SAS Time Variable Question</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-Time-Variable-Question/m-p/128232#M26205</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The CARDS statement (you can also use DATALINES statement if you are too young to remember what a card punch is) tells SAS to treat the following lines as data rather than commands. I just copied your data from the original post. I copied it out of the HTML table and just pasted it as raw text.&amp;nbsp; So the last two numbers on each line of data are your X and Y concentration values.&amp;nbsp; SAS stops reading when it sees a semi-colon (;) on the line.&amp;nbsp; You can also read from a text file by using an INFILE statement before the INPUT statement instead of the CARDS.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The INPUT statement tells it how to read the data. The first field is character, hence the $. The date and time fields have informats to tell SAS how to interpret the character strings as date and time.&amp;nbsp; The : modifier tells it not to read too many characters. For example when the hour part of the time is less than 10 so that the time value only uses 7 characters instead of 8.&amp;nbsp; The default informat is numeric so for the two concentration values I do not need to specify an informat.&lt;/P&gt;&lt;P&gt;The FORMAT statement tells SAS how to display the date and time variables so that humans can read them.&amp;nbsp; I prefer to use Y/M/D order to display dates to avoid confusion between US default of M/D/Y and European default of D/M/Y.&amp;nbsp; Also then the text string will sort in chronological order.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If your data is already in a dataset then you do not need to INPUT it. If you have it in a spreadsheet then you could try using PROC IMPORT to convert it to a dataset.&lt;/P&gt;&lt;P&gt;The INT(time/'06:00't) will divide the time (number of seconds since midnight) by the number of seconds in 6 hours and truncate to just the integer part. So you will get 0,1,2 or 3.&amp;nbsp; I then added one so that the categories start from 1 instead of 0.&amp;nbsp; To get them to display as you want you could use a format.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;proc format ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; value tod 1='overnight' 2='morning' 3='afternoon' 4='evening' ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;run;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;To create time of day categories as a character string using your time ranges you might just use IF/THEN logic. For example to create the categories as a character variable your could try:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;if&amp;nbsp; time &amp;lt; '06:00't then tod='overnight';&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;else if time &amp;lt;'12:00't then tod='morning';&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;else if time &amp;lt;'18:00't then tod='afternoon';&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;else tod='evening';&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 22 Sep 2012 17:19:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-Time-Variable-Question/m-p/128232#M26205</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2012-09-22T17:19:33Z</dc:date>
    </item>
    <item>
      <title>Re: SAS Time Variable Question</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-Time-Variable-Question/m-p/128233#M26206</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Tom,&lt;/P&gt;&lt;P&gt;Thank you SO much! I understand you completely. Thank you for taking time out of your Saturday to help a newbie like myself. Much appreciated!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 22 Sep 2012 18:15:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-Time-Variable-Question/m-p/128233#M26206</guid>
      <dc:creator>dubya</dc:creator>
      <dc:date>2012-09-22T18:15:23Z</dc:date>
    </item>
    <item>
      <title>Re: SAS Time Variable Question</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-Time-Variable-Question/m-p/128234#M26207</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Can I ask you one more question in regards to days of the week?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;data sample;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; input location $ date :mmddyy10. x y;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; format date yymmdd10.;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; dow=weekday(date);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;will this code alone give me day of the week variable? How would I go from a date of 10/9/2009 to "Monday" (not sure if that is the correct date but just as an example)?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 22 Sep 2012 18:31:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-Time-Variable-Question/m-p/128234#M26207</guid>
      <dc:creator>dubya</dc:creator>
      <dc:date>2012-09-22T18:31:20Z</dc:date>
    </item>
    <item>
      <title>Re: SAS Time Variable Question</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-Time-Variable-Question/m-p/128235#M26208</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The WEEKDAY() function returns a number from 1 to 7.&amp;nbsp; You could create your own format to display the names.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The DOWNAME format will display a date as the Sunday, Monday, etc.. You could use it with the PUT() function to generate a new character variable.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;weekday=put(date,downame.);&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 22 Sep 2012 21:00:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-Time-Variable-Question/m-p/128235#M26208</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2012-09-22T21:00:51Z</dc:date>
    </item>
    <item>
      <title>Re: SAS Time Variable Question</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-Time-Variable-Question/m-p/128236#M26209</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you so much, Tom, with your help, I figured it out and was able to build some code that works! You ROCK!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 23 Sep 2012 22:46:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-Time-Variable-Question/m-p/128236#M26209</guid>
      <dc:creator>dubya</dc:creator>
      <dc:date>2012-09-23T22:46:01Z</dc:date>
    </item>
  </channel>
</rss>

